Forum Discussion
Bespoke icon for conditional formatting
Hi team, I need to create new bespoke icons using images from our comms team. So, for example, when a team name is used in a graph instead of the 'name' being displayed the 'icon/image' is displayed instead.
I have looked through the different forms around customising icons etc but can't see one on using a bespoke icon, and a proper step by step ‘dummies guide’ to getting this into the Power BI icon drop down list (as shown below).
Or is there a better way to do it? A rule when the 'text' is used then use the corresponding ‘image’? Not sure how that would work??
NOTE: All bespoke icons from comms are currently PNG files.
1 Reply
- OwenAugerSuper User
Hi Sabz13
Here are some suggested answers:
Note 1: I have attached a JSON file containing 4 custom icons, and a PBIX using those icons.
Note 2: In code blocks, the forum converts colon characters to &colon. If you are copying the code, please change these back to actual colon characters 🙂
1. Adding Icons to Theme
- This is a pretty good guide
https://pbivisuals.com/2021/10/29/how-to-add-custom-icons-in-power-bi-conditional-formatting/ - As the guide states, you need to convert your PNG files to Base64 URLs similar to that shown below.
- My attached JSON file has 4 custom icons.
- To add the theme in Power BI Desktop: View > Theme > Browse for Themes > Select file
- Here is a bare minimum theme containing just one icon:
{ "name": "Custom Icons", "icons": { "Checkers": { "description": "My Grey Checkers", "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII" } } }2. Applying these icons in Power BI Desktop
- After adding the Theme in Power BI Desktop, the icons are visible in the drop-down list in the Icon Conditional Formatting dialog box.
- Note that the "description" shows on hover.
- You can also create a measure that returns the icon's name (e.g. "Pennywise" in my example), and select this measure when using Format Style = Field Value.
- In my PBIX, I added an "Icon" column to my table which contains valid icon names as text, and created a Selected Icon measure which retrieves the current text value from this column. As long as the value returned by the measure is a valid icon name, this will work fine.
Selected Icon = SELECTEDVALUE ( Score[Icon] )- The built-in icons also have names. See here
https://radacad.com/power-bi-icon-names-for-conditional-formatting-using-dax
Some screenshots below:
Icon drop-down menu:
Field value method with measure [Selected Icon]
Visual with conditional formatting using icons
Regards,
Owen
- This is a pretty good guide