Skip to content

Instantly share code, notes, and snippets.

@PBI-DataVizzle
Forked from cbaragao/5by5waffle.txt
Created November 19, 2023 14:34
Show Gist options
  • Save PBI-DataVizzle/4028a0b9adff826078a5fdb0809a275f to your computer and use it in GitHub Desktop.
Save PBI-DataVizzle/4028a0b9adff826078a5fdb0809a275f to your computer and use it in GitHub Desktop.
5x5 Waffle =
VAR _max = 500
VAR _actual = 120
VAR _waffles = ROUND((_actual/_max) * 50, 0)
VAR _gray = "#7A7979"
VAR _red = "#FF0000"
VAR _header = "data:image/svg+xml;utf8,<svg width=""200"" height=""200"" viewBox=""0 0 200 200"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
<rect width=""200"" height=""200"" fill=""white""/>"
VAR _footer = "</svg>"
VAR _base =
{
(1,"<rect x=""33"" y=""34"" width=""25"" height=""25"" fill=""","""/>"),
(2,"<rect x=""33"" y=""61"" width=""25"" height=""25"" fill=""","""/>"),
(3,"<rect x=""33"" y=""88"" width=""25"" height=""25"" fill=""","""/>"),
(4,"<rect x=""33"" y=""115"" width=""25"" height=""25"" fill=""","""/>"),
(5,"<rect x=""33"" y=""142"" width=""25"" height=""25"" fill=""","""/>"),
(6,"<rect x=""60"" y=""34"" width=""25"" height=""25"" fill=""","""/>"),
(7,"<rect x=""60"" y=""61"" width=""25"" height=""25"" fill=""","""/>"),
(8,"<rect x=""60"" y=""88"" width=""25"" height=""25"" fill=""","""/>"),
(9,"<rect x=""60"" y=""115"" width=""25"" height=""25"" fill=""","""/>"),
(10,"<rect x=""60"" y=""142"" width=""25"" height=""25"" fill=""","""/>"),
(11,"<rect x=""87"" y=""34"" width=""25"" height=""25"" fill=""","""/>"),
(12,"<rect x=""87"" y=""61"" width=""25"" height=""25"" fill=""","""/>"),
(13,"<rect x=""87"" y=""88"" width=""25"" height=""25"" fill=""","""/>"),
(14,"<rect x=""87"" y=""115"" width=""25"" height=""25"" fill=""","""/>"),
(15,"<rect x=""87"" y=""142"" width=""25"" height=""25"" fill=""","""/>"),
(16,"<rect x=""114"" y=""34"" width=""25"" height=""25"" fill=""","""/>"),
(17,"<rect x=""114"" y=""61"" width=""25"" height=""25"" fill=""","""/>"),
(18,"<rect x=""114"" y=""88"" width=""25"" height=""25"" fill=""","""/>"),
(19,"<rect x=""114"" y=""115"" width=""25"" height=""25"" fill=""","""/>"),
(20,"<rect x=""114"" y=""142"" width=""25"" height=""25"" fill=""","""/>"),
(21,"<rect x=""141"" y=""34"" width=""25"" height=""25"" fill=""","""/>"),
(22,"<rect x=""141"" y=""61"" width=""25"" height=""25"" fill=""","""/>"),
(23,"<rect x=""141"" y=""88"" width=""25"" height=""25"" fill=""","""/>"),
(24,"<rect x=""141"" y=""115"" width=""25"" height=""25"" fill=""","""/>"),
(25,"<rect x=""141"" y=""142"" width=""25"" height=""25"" fill=""","""/>")
}
VAR _add_colors =
ADDCOLUMNS(_base, "color", IF([Value1]<= _waffles, _red, _gray))
VAR _body = CONCATENATEX(_add_colors, [Value2] & [color] & [Value3])
VAR _output = _header & _body & _footer
RETURN _output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment