Creating a dark and light theme for your Power BI report

Erik Hamoen
4 min readAug 9, 2022
Photo by Abed Ismail on Unsplash

Since I started working in BI, I saw a lot of colleagues using dark mode options, whenever they could. And when Microsoft revamped the desktop application to a light one, there were so many people asking for an option to change it back to dark. As far as I know, this hasn’t happened so far, but you can give your report users the option to change a report from light to dark! And before we start, I got to confess something: I love the light colors! #Hatersgonnahate

Setup

First, I start with creating a (disconnected) table in my data model. We will only need one column with the values Light and Dark, but I also like to add the color codes I’m going to use, and in this specific case I’m using an emoji to put in my slicer.

This is what my table looks like:

Table with colorcodes

Now I’m creating a visual and what I want to achieve is that the background changes based on the selection I make: Light or Dark. To do that, I create a measure that takes the selection of a slicer to filter which background color must be shown:

Dark & Light Background =
SWITCH (
TRUE (),
SELECTEDVALUE ( ‘Day & night’[Status] ) = “🌙”, VALUES ( ‘Day & night’[Colorcode Background] ),
SELECTEDVALUE ( ‘Day & night’[Status] ) = “☀️”, VALUES ( ‘Day & night’[Colorcode Background] ),
“#E8E8E8”
)

Now whenever nothing is selected, it will choose my light color background. In the formatting options of my graph I’ll go General, Effects and select the formatting conditional formatting option for the background.

Formatting options for your visual

Then I select Field values and select the measure I just created:

Conditional formatting rules

This is the result of my dark theme:

Dark colors for my graph

It’s a great color but the labels are invisible! So, I create another measure for a light and dark label. The measure is slightly different because now I want to reverse the colors:

Dark & Light Labels =
SWITCH (
TRUE (),
SELECTEDVALUE ( ‘Day & night’[Status] ) = “🌙”, VALUES ( ‘Day & night’[Colorcode Labels] ),
SELECTEDVALUE ( ‘Day & night’[Status] ) = “☀️”, VALUES ( ‘Day & night’[Colorcode Labels] ),
“#202020”
)

When I apply this measure to the condition formatting, my result looks like this. Much better:

Dark colors for my graph with light labels

Now for piecharts, this works the same: Title, labels, legends. But for tables, we got some issues:

Dark theme Power BI table

The background works fine, but our table looks terrible like this. And I can’t use conditional formatting in the table itself. Therefore, I must use the Cell Element options:

Cell options for the Power BI Table
Result of the Cell Element option

Now I will also need to do this for the other column, and for the total row, I don’t have a condition formatting option as well. So, I chose a color that works ‘okay’ on both background colors. (#CCCCC) After I added some extra visuals the report looks like this:

Full Power BI report in dark mode

I guess my colleagues would say there is still too much light white between the colors, so let’s change the background color! Again, there is no option for conditional formatting, but we can use a shape and move it to the background to solve this. First I turn off the Fill effect and for the background color I use the following measure:

Dark & Light Background Style =
SWITCH (
TRUE (),
SELECTEDVALUE ( ‘Day & night’[Status] ) = “🌙”, “#000000”,
SELECTEDVALUE ( ‘Day & night’[Status] ) = “☀️”, “#f5f5f5”,
“f5f5f5”
)

I chose some different colors, so you would still see where the visual background is. And after some extra tweaking (creating a bookmark, changing my slicer for some images) this is my result:

Dark and Light theme for Power BI

Wrap up

As you can see it’s easy and straightforward to create a dark and light theme in Power BI, but for some visuals, you got to do a little bit of extra work. And it doesn’t just stop at dark and light. You can also make High contrast, Color Blind friendly, and so on.

Take care.

--

--