Power BI: Referencing Theme Colors Directly in Visuals (pbip + visual.json)

Even though Power BI’s color picker doesn’t offer Sentiment colors (Good/Bad/Neutral) and Divergent colors (Min/Mid/Max), you can bind visual properties directly to these semantic color tokens. The trick: save your report as a Power BI Project (.pbip), open the visual.json of the respective visual, and replace hard-coded hex values with the desired color codes (e.g., good, bad, neutral, minColor, midColor, maxColor). From that point on, your theme controls the colors centrally, without manual recoloring in the UI.

🔎 Important clarification: The editable JSON files (including visual.json) are available with .pbip (Power BI Project), not with .pbit (Template). Templates are still useful, but for directly editing visual definitions you need .pbip.


Context & connection to earlier posts

This article extends both perspectives: we now bind colors directly in the visual, while keeping them centrally manageable through the theme.


What Power BI doesn’t (yet) offer in the UI and what still works

The color picker currently lacks semantic theme colors, even though dedicated tokens exist in the theme JSON. We can close this gap manually via the visual.json of the respective visual.

Power BI: Color picker vs. sentiment/divergent from the theme (mockup)

Advantage: You get the best of both worlds – visuals remain bound to the theme, while the UI remains flexible. If you later change, for example, good in the theme, all visuals linked to it update automatically.


Step-by-step: Binding a visual to theme colors

⚠️ Prerequisite: Power BI Desktop with Power BI Project (.pbip) enabled. Save your report as .pbip and work on a copy (version control pays off).

  1. Save as .pbip
    File → Save As → File type Power BI Project (.pbip). Your report is now stored as a folder structure.
  2. Open the visual.json of the target visual
    NNavigate to the corresponding report section/visual (e.g., Report/definition/pages/<id>/visuals/<id>/visual.json).
  3. Locate the color property
    Look for a property with a hard-coded hex value, for example:
{
  "fill": {
    "solid": {
      "color": {
        "expr": {
          "Literal": {
            "Value": "'#E91E63'"
          }
        }
      }
    }
  }
}
  1. Replace hex value with a semantic token
    Replace the hex value with a theme token such as good, bad, neutral, or for divergent colors: minColor, midColor, maxColor.
{
  "fill": {
    "solid": {
      "color": {
        "expr": {
          "Literal": {
            "Value": "'good'"
          }
        }
      }
    }
  }
}

💡 Note: JSON structure can vary depending on the visual and property. Rule of thumb: wherever a hex value is used, a token often works as well. Look for fields like color, fill, foreground, background, etc.

  1. Save & reload in Desktop
    Save the file. When reopening the .pbip in Power BI Desktop, the color should now come from the theme. Test by changing the corresponding token in your theme.

Key color tokens (selection)

Power BI supports a set of semantic color identifiers that can be defined in the theme and referenced in visual.json. A (non-exhaustive) selection:

  • Sentiment: good, neutral, bad
  • Divergent: minColor, midColor, maxColor
  • Other useful tokens (depending on theme/visual): tableAccent, foreground, background, hyperlink, visitedHyperlink, disabledText, shapeStroke, etc.

The following overview from my LinkedIn post shows some of the codes I found:

Exemplary list of color codes that Power BI understands

ℹ️ Reality check: Not every visual or property supports every token. If a token doesn’t work, check the specific property, the visual type, or whether another formatting setting (e.g., via UI) overrides it.


Theme file: Where the colors come from

In Power BI, you can view and adjust your current theme via the View ribbon:
View → Themes → Customize Current Theme. A dialog opens where you can edit key values such as accent colors, background, and text colors. Any change here (e.g., the accent color) immediately applies across the entire report.

📚 Highly recommended reading: SQLBI, “Re-using visual formatting in and across Power BI reports” – a deep dive into reusing formatting, themes, and best practices for maintainability: https://www.sqlbi.com/articles/re-using-visual-formatting-in-and-across-power-bi-reports/


Best practices & pitfalls

  • Use version control (e.g., Git) when editing .pbip and JSON files.
  • UI formatting can override tokens. If a hex value is set in the UI, it usually takes precedence over the theme token.
  • Not supported everywhere. Some visuals or properties only accept hex/palette values. In those cases, the DAX approach from my earlier article may still be required.
  • Portability: .pbip is excellent for teamwork and clean artifacts – but ensure your build/deployment processes support the project structure.

Wish for Microsoft: Tokens in the color picker!

For consistency and maintainability, it would be ideal if the color picker directly offered Sentiment and Divergent colors (and other semantic tokens) – with full theme binding.

I found a related Fabric Idea – please vote:
https://community.fabric.microsoft.com/t5/Fabric-Ideas/Possiblity-to-name-colors-in-theme-color-selection/idc-p/4817910


Fazit

  • Yes, theme colors can be referenced directly in visuals – even without UI support.
  • Yes, this allows central control through the theme, reducing manual formatting.
  • And yes, until Microsoft integrates tokens into the color picker, the pbip + visual.json approach is a practical workaround.

Veröffentlicht von

Marcus Wegener

Marcus Wegener

Marcus Wegener ist Anwendungsentwickler für Business Intelligence und erstellt Lösungen, mit denen sich große Datenmengen schnell analysieren lassen. Kunden nutzen seine Lösungen, um die Vergangenheit zu analysieren, die Gegenwart zu steuern und die Zukunft zu planen, um damit mehr Erfolg zu generieren. Dabei ist seine einzigartige Kombination aus Wissen und Auffassungsgabe ein Garant für ihren Erfolg.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

I accept that my given data and my IP address is sent to a server in the USA only for the purpose of spam prevention through the Akismet program.More information on Akismet and GDPR.