March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Just like SVG SparkLines this DAX produces a Trend indicator, Up/Down/Neutral.
Add it as a field in your table, keyed off a numeric value to give you the up/down/neutral.
One additional trick is to set the image size as small as possible (24) under Grid as part of the formatting.
Trend_Image =
VAR MessageText = ""
VAR Radius = 9
VAR Colour = "blue"
VAR Opacity = 0.75
VAR SVG_Neutral = "data:image/svg+xml;utf8," &
"<svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='50' height='20'>" &
"<circle cx='25' cy='10' r='" & Radius & "' fill='" & Colour & "' fill-opacity='" & Opacity & "' />" &
"</svg>"
VAR SVG_UP = "data:image/svg+xml;utf8," &
"<svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='50' height='20'>" &
"<polygon points=""05,20 45,20 25,1"" style=""fill:green;stroke:green;stroke-width:0;fill-rule:evenodd;"" />" &
"</svg>"
VAR SVG_DN = "data:image/svg+xml;utf8," &
"<svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='50' height='20'>" &
"<polygon points=""05,1 45,1 25,20"" style=""fill:red;stroke:red;stroke-width:0;fill-rule:evenodd;"" />" &
"</svg>"
RETURN
IF('Customer KPI'[KPI_Trend] > 0, SVG_UP, IF('Customer KPI'[KPI_Trend] < 0, SVG_DN, SVG_Neutral))
Thank you.
Yes an issue with copy & paste. and Having tried it again, the editor here is doing "fancy" stuff that I cannot work around.
The "magic" is attached in an image below.
This doesn't seem to work in the latest update of PowerBI service - I get a missing image placeholder instead of the SVG. Any idea why that might be? It still works fine in PBI Desktop but not in the service.
Thanks,
Tom
Likely a browser issue. Or browser version issue.
Does it work in Chrome?
- David
Getting the same issue
Microsoft have acknowledged it is a bug and i'm awaiting details of a fix. For now I had to bake the SVGs I wanted into files and host them then use a web URL as usual.
I did notice that the images are still honoured if you export to PDF and it works in Edge just not other browsers.
Very interesting....I have the same issue. For me, it is broken in Chrome, Edge, and Firefox however it works in Opera!
Any news from Microsoft? I opened a support ticket a week ago and have heard nothing back from them.
My ticket is still open and they are still discussing a solution as far as I know. I last heard from them a couple of days ago.
Microsoft have fixed this and should be released first week of April.
OK, SVG's are now rendering in tables, but not any of the image custom visuals... Which is not ideal as I cannot switch the column headings off for tables...
Any update? Doesn't appear to be fixed yet?
OK - good to hear. Thanks
That's really weird. "Everything" works in Chrome.
The SVG code that you have (or are generating)... you can place in a txt file xyz.svg and open that in the browser... so you can test outside of Power BI. There maybe something in the SVG code or headers that is breaking the browser compatability?
- David
Just tried that and the SVG is sound. I have deployed this with different SVGs in 3 different projects and they all simultanously broke with the Feb update of PBI so there must be a change in PBI somewhere. I thought it might be due to "external" images so I took the URL of an SVG that I found online and put it into a table and set it to Web Image but that worked fine.
Will keep you posted with what Microsoft say. They've asked for the PBIX file.
Thanks for the help,
Tom
Thanks a lot for posting this - it's fantastic!
The DAX didn't work out of the box for me (I got the broken image icon) but I followed the link in your other DAX based sparkline post and saw that the prefix for the SVG data was slightly different. I think the forum is changing the code when you save it.
If you replace the ":" in the code with an actual colon it works perfectly.
Thanks again,
Tom
Thank you.
Yes an issue with copy & paste. and Having tried it again, the editor here is doing "fancy" stuff that I cannot work around.
The "magic" is attached in an image below.
That's a good question. I haven't used it in a total row.