This article shows how to use a Tabular Editor 3 C# script library to add SVG measures to Power BI report visuals without hand-writing each SVG specification.
Short on time? The link to the template library is here.
In Power BI there are many options to create custom visuals for your reports. An increasingly popular technique is to create DAX measures that contain a dynamic SVG specification. These “SVG measures” render as small custom visuals in certain visuals like tables, matrixes, and the card visual. These visuals allow for pixel-perfect control and can result in some creative and powerful charts.
You can see an example of these SVG visuals below:
However, creating these SVG specifications is complex, time-consuming, and prone to error. Furthermore, these measures can be a burden for the semantic model; if they aren’t placed in separate tables and display folders, users might confuse them with proper model measures.
To mitigate these costs, many in the Power BI community have shared their own SVG visual templates, but those less experienced in Power BI or in dealing with SVGs might struggle to implement these templates in their own work. To help with this, we’ve created a library of C# scripts to streamline the implementation of these templates. This library includes over two dozen original visual designs that you can use in your own Power BI reports.
Figure 2: The library contains over two dozen templates of various chart types. Most templates focus on comparing actual versus target for a single category but can be extended to multiple targets and multiple categories. The number of templates is growing over time, and community contributions are welcome.
This library of templates is maintained by Kurt Buhler (Data Goblins) and was created in collaboration with Tabular Editor. If you want to convert an SVG template to a C# script template, contact Kurt Buhler via the appropriate social media channels (LinkedIn or X).
Watch the walkthrough video on YouTube
These scripts are provided as a “plug-and-play” solution for Tabular Editor 3. To use them, simply follow the instructions below:
DataCategory and Description.You will need to adjust the resulting DAX code in the measure if you want to customize the visual to your specific needs. Examples of this might be adjusting the color or size, changing it to work with multiple categories or targets, or adding either vector properties (like stroke) or new vectors (like labels).
We hope that these C# scripts and SVG visual templates can help you to improve your reports. Creating and using templates for your data models and reports is an important step to not only improve your productivity but also can help improve the maturity of your team and organization in reporting. One way to do this is by using C# scripts in Tabular Editor, which are beneficial not only for creating data models, but also visuals.
Take your semantic models further with Tabular Editor.
Give Tabular Editor a spin