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
10-12-2024 03:40 AM
While it is easy to create sparklines in Power BI, challenges arise when using them in a matrix with a date or period field added to the columns. Instead of displaying a continuous line that goes up and/or down, you’ll see one dot for each period.
👉I used a disconnected table and a measure categorized as an Image URL, which returns SVG markup. The green and red lines on the month columns correspond to the green and red dots which are the highest and lowest points on the sparkline. The lines and the dots can be hidden if desired.
👉Currently, it's not possible to conditionally format data bars using a different measure, and they can't be done with text strings. Instead, they are set within the measure itself, where the width is based on the percentage of the current cell value relative to the grand total.
Things I wish were possible:
👉A dynamic data category that allows specifying which columns contain text and which hold images. If this were available, I wouldn't have had to render numbers as SVG but I wouldn't have added the lines as well. 😁
👉A native visual that permits adding a custom column or adjusting settings for which measure applies to a particular row or column field.
Things I couldn't accomplish (but maybe you can):
👉Dynamically changing the font weight within the SVG so that, if a lower level in the hierarchy is expanded, the current level displays in bold font; otherwise, it remains in a regular weight.
👉Using a calculation group without explicitly referencing a measure. I tried this, but the result was categorized as text.
I used a dummy 1 px page tooltip so the code doesn't show when a cell is hovered as disabling the tooltip in the settings doesn't really disable it.
SVG codes were created with the help of AI.
There is always a space before an image that cannot be removed from the visual settings.
Exporting the data from the viz will return the SVG codes instead of the actual values.
Sample pbix and tutorial on YouTube - https://www.youtube.com/watch?v=VPjmterIX7c
eyJrIjoiOTkyN2VmYzctYzcxOC00NDZjLWE4MzktOTkwMzA2YTc4NGEwIiwidCI6ImRmODY3OWNkLWE4MGUtNDVkOC05OWFjLWM4M2VkN2ZmOTVhMCJ9
Proud to be a Super User!
I couldn't get access to the link in Youtube https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbFdrc3kycDBBdzdoZGg1RjQ...
I liked this: disconnected table and a measure categorized as an Image URL, which returns SVG markup