I am trying to make a sparkline chart with categorical data in power bi. I have used the following code for the chart, but it is not showing me a chart.
bar table sparkline =
// static column color - use %23 instead of # for firefox compatibility
VAR BarColor = "%2301B8AA"
VAR BarOutlineColor = "%23DDDDDD"
VAR BarOutlineWidth = 2
// Obtain number of columns - width genrated based on column count
VAR BarCount = DISTINCTCOUNT('Virtual Table'[type])
VAR BarWidth = INT(DIVIDE(100,BarCount))
// Obtain overall min and overall max measure values when evaluated for each date
VAR YMinValue = MINX(VALUES('Virtual Table'[type]),CALCULATE(AVERAGE('Virtual Table'[field widget])))
VAR YMaxValue = MAXX(VALUES('Virtual Table'[type]),CALCULATE(AVERAGE('Virtual Table'[field widget])))
VAR YRange = SWITCH(TRUE(),
YMinValue >= 0 && YMaxValue >= 0, YMaxValue,
YMinValue < 0 && YMaxValue < 0, ABS(YMinValue),
YMaxValue + ABS(YMinValue))
VAR SparklineTable = ADDCOLUMNS(
SUMMARIZE('Virtual Table','Virtual Table'[type]),
"X",INT(RANKX('Virtual Table','Virtual Table'[type],'Virtual Table'[type],ASC,DENSE)),
"Y",SWITCH(TRUE(),
YMinValue >= 0 && YMaxValue >= 0, 100-INT(100 * DIVIDE(AVERAGE('Virtual Table'[field widget]),YMaxValue)),
YMinValue < 0 && YMaxValue < 0, 0,
YMinValue < 0 && YMaxValue >= 0 && AVERAGE('Virtual Table'[field widget]) >= 0, INT(100 * DIVIDE(YMaxValue - AVERAGE('Virtual Table'[field widget]),YRange)),
YMinValue < 0 && YMaxValue >= 0 && AVERAGE('Virtual Table'[field widget]) < 0, INT(100 * DIVIDE(YMaxValue,YRange))
),
"Height", INT(100 * DIVIDE(AVERAGE('Virtual Table'[field widget]),YRange))
)
// Concatenate X & Y coordinates to build the sparkline
VAR Cols = CONCATENATEX(SparklineTable,"<rect x='" & [X] * BarWidth - BarWidth &
"' y='" & [Y] &
"' width='" & BarWidth &
// display slim bar if height = 0
"' height='" & IF([Height] = 0, 1, ABS([Height])) &
"' style='fill:" & BarColor &
";stroke-width:" & BarOutlineWidth &
";stroke:" & BarOutlineColor &
"' />","")
VAR SVGImageURL =
"data:image/svg+xml;utf8," &
"<svg xmlns='https://www.w3.org/TR/SVG2/' x='0px' y='0px'
viewBox='0 0 100 100'>" &
Cols &
"</svg>"
RETURN SVGImageURL
Instead of a chart, I get description of the chart.