Search

Search this blog:

Search This Blog

Power BI Themes


I am a big fan of color; my wardrobe is full of blues and pinks and yellows. Side note: have you ever heard of 'dopamine dressing'? Apparently it's a fashion trend that's been around since at least 2022 but I'm just learning about it now - I'm actually impressed I'm only a season or two behind! 

But I digress, the reason for my post today is to compile some of my favorite resources for working with color in Power BI, and more generally, Power BI themes.


Sentiment Colors in Bar chart


Colors have meaning

Being a good data storyteller means using all the tools at your disposal. This includes color. It is important to note that I'm not advocating the use of color only in your reports - you need to ensure that there is another method to discern what's going on with the data for those in your audience who might be colorblind. But that doesn't mean we can't play around with color and use it to add meaning to our reports. 

Most people I know would agree that GREEN means 'Good' and RED means 'Bad'. But colors can be very personal. For example, my favorite color is BLUE and it was also the color I chose for my math notebooks throughout school. (Yes, math was my favorite subject - I guess it's no surprise I ended up in a career that works so much with data.) My school subjects were always color coded as follows:

  • BLUE - Math
  • GREEN - Science
  • RED - English
  • YELLOW - History

So what does this mean for your Power BI reports? Use color to your advantage. You may not be reporting on school subjects, but you can assign colors to whatever categories or metrics you're reporting on according to your own meaning and interpretation. BLUE is also the color of the sky, water, a common color in many country's flags and so much more. Using the AdventureWorks Sales data as an example, you could assign colors to the product categories as follows:

  • GREEN - Bikes
  • PURPLE - Accessories
  • YELLOW - Components
  • RED - Clothing

If you're reporting on 2 or 3 different metrics, assign a different color to each one and use that consistently throughout your report:

  • BROWN - Actual
  • RED - Budget
  • Light BROWN - Prior Year Actual

Whatever colors you use, make sure you're using them deliberately and with meaning. Adding lots of extra color to your report may give the impression that it's more exciting, but it may have the unwanted result of making your report more difficult to read and understand.

Create your own Power BI theme

I've written a few posts on Power BI themes, and the functionality of themes in Power BI desktop has improved dramatically over the years. 

You have a few options when creating your own theme in Power BI:

  1. Use the built-in theme designer within Power BI desktop
  2. Import a theme someone else has created in JSON
  3. Create and import your own theme using JSON

It used to be extremely difficult to find documentation for creating your own JSON theme in Power BI, but that has gotten easier. The Microsoft Learn article Use report themes in Power BI Desktop - Power BI | Microsoft Learn is a great place to start. 

However, with the speed of development of Power BI desktop, there's just not enough documentation on the new visuals. 

This is a great start: powerbi-desktop-samples/Report Theme JSON Schema at main · microsoft/powerbi-desktop-samples · GitHub

But not everything is documented there. One trick I've learned is that you can use the Power BI project files to explore the JSON code in Power BI desktop and copy that into your own theme. 

How to find the JSON code for formatting visuals in Power BI themes

For example, I'm going to use this method to find the formatting options for Power BI themes.

Step 1: Add the visual you want to format in your theme to a new blank report. 

Step 2: Change the formatting options that you want available for editing within your theme.

Step 3: Save AS - save your report as a .pbip file. When you choose this option, Power BI will save a couple folders with various files into the folder you choose.

Step 4: Open the visual.json file - you'll find this in the MyReportsName.Report > definition > pages folder. This can be difficult to navigate which is why I start Step 1 with a blank new report.

Step 5: Explore the code to discover the names of the visual and the properties.

Step 6: Use those names in your JSON theme, following the instructions from Use report themes in Power BI Desktop - Power BI | Microsoft Learn 

Power BI Color Picker

While my go-to resource for anything color related is usually Coolors.co - I've been inspired to make my own little color picker that calculates the contrast and displays a demo live in Power BI. The thing I like about this tool that I've created is it lets you adjust the colors using RGB method, so if you want to just add a bit of red hue you can, and the contrast value is calculated automatically without needing to switch tools. 

It makes me feel almost like an artist mixing colors in a paint palette. Except, since we're playing with digital colors, mixing the maximum value of all three colors makes white. This follows the light color spectrum, where white light indicates the presence of all colors, and black is the absence of all colors. So if you select 0 for each RGB value, you'll get black.

Have a play with the color picker below and see what you think!


Reference Power BI theme colors in DAX

Now for the REALLY cool bit: this is the straw that finally inspired me to publish today's blog - I was doing research for a talk I was giving and came across this Workout Wednesday challenge on using Power BI theme colors within your DAX:

2024 Week 26 | Power BI: Reference Theme Sentiment Colors in DAX – Workout Wednesday (workout-wednesday.com)

(If you haven't heard of Workout Wednesday - I highly recommend you check them out. They have fantastic demos and challenges for all skill levels and it's a great way to get inspiration.)

This is something I've wanted to do for years, but haven't known how. Just like with everything else in Power BI themes, it all comes down to know which names to use. 

So far, I have discovered the following color names from the theme can be used in your DAX code:

  • good
  • neutral
  • bad
  • maxColor (note this is called 'maximum' in the theme)
  • midColor (note this is called 'center' in the theme)
  • minColor (note this is called 'minimum' in the theme)
  • tableAccent
  • foreground (note this is also called 'firstLevelElements' in the theme)
  • foregroundNeutralSecondary (note this is also called 'secondLevelElements' in the theme)
  • backgroundLight (note this is also called 'thirdLevelElements' in the theme)
  • foregroundNeutralTertiary (note this is also called 'fourthLevelElements' in the theme)
  • background 
  • backgroundNeutral (note this is also called 'secondaryBackground' in the theme)

Sample Theme Colors with DAX conditional formatting

Thanks also to thinkBI for inspiring me to see what other theme colors are available for use beyond what was in the WOW solution. 


References I used to study up for this blog post:

2024 Week 26 | Power BI: Reference Theme Sentiment Colors in DAX – Workout Wednesday (workout-wednesday.com) - the original inspiration for this post and source of some working theme color names in DAX.

Color Contrast Checker - Coolors - one of my go to resources whenever I need to do something with colors.

Reference Power BI theme colors in DAX - thinkBI - source of some additional working theme color names in DAX that inspired me to test out all the theme colors I know the names for.

Choosing font color based on background color in Power BI – XXL BI - Special thanks to Daniil Maslyuk for his measure on font color and David Eldersveld's comment that inspired me to convert it to use Luminance instead of Intensity.

Color Relative Luminance Calculator (WCAG) (contrastchecker.online) - to learn how to calculate Luminance.

RGB - Hexadecimal Color Conversion (tripod.com) - to learn how to convert HEX to RGB and better understand what had been done by Daniil in his Font Color measure.

List of Unicode characters - Wikipedia - again, to better understand what had been done by Daniil.

Chris Webb's BI Blog: Colour Names Supported In Power BI Conditional Formatting (crossjoin.co.uk) - Chris Webb has been one of my go to blogs for many years. This particular post is quite old and many of these colors no longer seem to work in Power BI DAX, but it led me to the correct link of CSS colors that did all seem to work in DAX.

CSS Colors (w3schools.com) - the correct link of CSS colors that work in Power BI DAX.

JSON Editor Online: edit JSON, format JSON, query JSON 

powerbi-desktop-samples/Report Theme JSON Schema at main · microsoft/powerbi-desktop-samples · GitHub - JSON code for many of the classic Power BI visuals.

Power BI Icon Names for Conditional Formatting Using DAX - RADACAD - Not used in this blog but a really great resource for conditional formatting in DAX. 


Custom Visual Review: Charticulator

This is not your ordinary custom visual - this is EVERY custom visual. Charticulator puts the power to design and develop custom visuals to ...