Add an embedded background image to your Power BI Theme

Power BI is a very popular visualization tool by Microsoft, allowing companies to do data exploration and analysis to gain a clearer insight into their data. One important aspect of bringing clear reports to your target consumers is how the report and visuals look. You can customize the design of your reports by applying a Power BI theme to make your reports visually better and more uniform across your organization. Microsoft offers a series of standard templates that you can choose from. It is most likely that you want to customize this to your own needs. Once you do this you can save the template as a JSON file and share it with your colleagues. Traditionally your company logo and other pictures you want to use as background needed to be imported and saved as part of your PBIX file. But did you know that there is a much more efficient way of doing this? In this blogpost I will show you what a Power BI theme can do and how you can create a unique background image which will be hardcoded into your Power BI theme.

What is a Power BI theme and why should you use it?

With Power BI themes, you can apply design changes to your report such as formatting the background color of your reporting canvas or visuals, adding your own corporate letter type, adding the official colors of your organization and many more. When you apply a theme to a report, all visuals will behave according to the specificities of that theme. The result will be that your report will have constant formatting without having to design each element individually. Creating a Power BI theme also saves a lot of time. You can create a custom theme within just a few clicks. One great advantage is that you can create multiple themes for each of your business units. Think about HR, Finance, Operations, etc. In this way it is easy for users to detect to which business unit a report belongs. Power BI themes can be saved into a JSON file, which we will discuss extensively later.

If you open your Power BI desktop app and select the view button on top, you will see a series of pre-defined Power BI templates. As mentioned before, you can completely customize a template. This is done by clicking on “customize current theme” as shown in the picture below.

Picture 1: how to navigate to Power BI themes

You can fully customize your template as you like but for now it is easiest to just change the background image to whatever color you like. The reason for this is explained in a later part of this blog. Here a light grey color is applied. Definitely make sure you apply a transparency as close as possible to 0%.

Picture 2: Format page background

Once you are done with this, click on apply and you have created a custom Power BI theme.

When you go back to the overview of the templates you will see that the “save current theme” button is now available. If you click on it, you can save your newly created template as a JSON file.

Picture 3: save the current theme

Now go to the place where you saved this JSON file and open it. I would recommend using Visual Studio Code. Format your document by selecting all text and right-mouse click on “format document”. You should have an output that looks like the following:

Picture 4: Output of formatted JSON-file

Adding a custom background

Now it is time to apply the trickiest part of creating your own custom Power BI theme. Adding your own created background as part of the theme. For this I would recommend opening PowerPoint. You can start from an empty slide and create a background as you like. Finally save that slide as a JPG format. If there is a background image already available in your organization, the better! Just verify that it is saved as a JPG. My background image looks like the following:

Picture 5: New created background

A tip can be to export the JPG in 300 dots per inch (dpi), which gives you a much higher resolution. The default value for a Powerpoint slide is 96dpi. More information can be found on: How to export high-resolution (high-dpi) slides from PowerPoint – Office | Microsoft Learn

Best practices are that you keep the background image as light as possible, don’t overdo it on the colors and make sure to give your logo’s a good place while guaranteeing enough space to work with your visuals.

Before continuing, the code between “background : [” and “, transparancy” needs to be deleted and replaced by the following code:

            {

                        “image”: {

                         “name”: “My_first_background_theme”,

                            “scaling”: “Fit”,

                            “url”: “data:image/jpeg;base64,”

                        }

As you can see in the picture below, you can give your Power BI theme a name. Feel free to choose any name you like. After you added the code, your output should look like the following:

Picture 6: Output JSON-file with code needed to insert base64 data

Now the JPG needs to be converted to a base64 formatted image. There are many websites online that offer this functionality. After you have transferred your image, go back to your JSON file.

Upload the base64 code right after the comma of the “base64” word and before the quotation mark in your JSON file. Don’t worry if your JSON file is now very long. Make sure you don’t remove the transparency to make sure the image is visible.

Picture 7: Place where base64 code needs to be Inserted

Now the JSON file with your uploaded image as base64 code needs to be saved first. Then you can go back to Power BI desktop. Once again go to view and now choose “browse for themes”. Here you can upload your JSON file. As you can see the image is now uploaded into your Power BI desktop.

Picture 8: Power BI theme with newly created background

From here on you can continue to work on your Power BI theme. Power BI themes offers more functionalities such as theme colors, the letter type, the background color, etc. You can even specify specific HTML color codes. The reason why it is best practice to only start from a background image and then upload your created background image is that it is easier to have an overview in your JSON file. If you would start by completing your Power BI theme first and then upload the image, it is easy to get lost.

Closing

Power BI is a powerful tool that can help you gain insights into your data. To make your reports look better, you can make use of Power BI themes. These are fully customizable. Instead of manually uploading your company logo(s) by a picture every time you create a Power BI file or by having to share the PBIX file you can create a custom background image and can hardcode this into your Power BI theme. You can do this for all business units. Therefore, you create uniform reports, and it is easier for business users to simply upload a JSON file. Instead of duplicating every page or repeating manual steps to upload a picture, you simply must open a new page in your reports and your custom background will be there.

Tibo Quinteyn

Tibo Quinteyn is a Microsoft analytics consultant with a passion for data visualization and engineering. Tibo started working at Lytix from September 2022. He is working as a data engineer at one of our clients using Azure data Factory, Power BI and Databricks. Tibo loves to create powerful reports for our customers and help them in any way he can.