How to get Donut Charts inside tables in Power BI using SVG
- 2 minutes read - 274 wordsWhen Microsoft enabled the ability for measures to have a data category such as image or web URL back in August of 2018. Quite a few people started using this to show dynamic images such as sparklines or KPIs. In this post I am going to built on these to create donut charts that can be embedded within Power BI Tables/Matrices using the same technique.
Measure 1: Five fixed values donut
This measure works by taking up to five specified measures and using them to build the donut chart.
Measure 2: TopN Donut
This measure works by taking a column and a measure, it then evaluates this measure for each distinct value in that column and constructs a donut chart.
Both measure 1 and measure 2 work in similar ways, by doing the calculations as to the coordiates required for the pie chart in DAX. Then using this to build up the SVG string with the measure set as Image URLs so that Power BI will render the images.
Measure 2 is slightly more complicated as it uses a CONCATENATEX to build up the string. This method makes the SVG and DAX code easier to follow in my opinion but comes at the cost of some flexibility.
If you are looking to take this even further you can look into using Report Page tooltips, or even rendering some more shapes or text within the SVG itself.
I hope these Power BI donut chart measures are helpful for your Power BI adventure, they are a great example of how Power BI can be enhanced outside of just the standard visuals.