Reference Power BI theme colors in DAX

Did you know that you can refer to the Divergent colors of the theme in DAX?  ?
Maybe I’ve seen it somewhere, but I can’t remember and it’s hard to find information about it on the internet.

Today my colleague Ulrik and I were optimizing a demo and asked ourselves whether we could use a DAX measure to match the conditional color formatting with the color stored in the theme.

After a short look at the report.json we found 3 color codes that actually work.

minColor = Divergent color Min
midColor = Divergent color Middle
maxColor = Divergent color Max

Power BI Theme Colors in DAX

Did you know it?
Does anyone know how to reference additional colors from the theme?

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.

Ein Gedanke zu „Reference Power BI theme colors in DAX“

  1. Nice find! I expanded a bit on your idea and built a measure to test various color codes. I reviewed the latest reportThemeSchema-2.127.json and noticed other keywords in the visualStyles section that appear to work as well.

    I’ve been trying to find a way to reference theme dataColors for a while now and still no luck.

    https://raw.githubusercontent.com/microsoft/powerbi-desktop-samples/main/Report%20Theme%20JSON%20Schema/reportThemeSchema-2.127.json

    Measure_ValueColor = SWITCH(
    TRUE(),
    [Measure_SelectedRowValue] = 0, “–fromJSONSCHEMA–“,
    [Measure_SelectedRowValue] = 1, “nullColor”,
    [Measure_SelectedRowValue] = 2, “foreground”,
    [Measure_SelectedRowValue] = 3, “firstLevelElements”,
    [Measure_SelectedRowValue] = 4, “secondLevelElements”,
    [Measure_SelectedRowValue] = 5, “thirdLevelElements”,
    [Measure_SelectedRowValue] = 6, “fourthLevelElements”,
    [Measure_SelectedRowValue] = 7, “background”,
    [Measure_SelectedRowValue] = 8, “secondaryBackground”,
    [Measure_SelectedRowValue] = 9, “good”,
    [Measure_SelectedRowValue] = 10,”neutral”,
    [Measure_SelectedRowValue] = 11, “bad”,
    [Measure_SelectedRowValue] = 12, “maximum”,
    [Measure_SelectedRowValue] = 13, “center”,
    [Measure_SelectedRowValue] = 14, “minimum”,
    [Measure_SelectedRowValue] = 15, “null”,
    [Measure_SelectedRowValue] = 16, “accent”,
    [Measure_SelectedRowValue] = 17, “tableAccent”,
    [Measure_SelectedRowValue] = 18, “foregroundLight”,
    [Measure_SelectedRowValue] = 19, “foregroundDark”,
    [Measure_SelectedRowValue] = 20, “foregroundNeutralLight”,
    [Measure_SelectedRowValue] = 21, “foregroundNeutralDark”,
    [Measure_SelectedRowValue] = 22, “foregroundNeutralSecondary”,
    [Measure_SelectedRowValue] = 23, “foregroundNeutralSecondaryAlt”,
    [Measure_SelectedRowValue] = 24, “foregroundNeutralSecondaryAlt2”,
    [Measure_SelectedRowValue] = 25, “foregroundNeutralTertiary”,
    [Measure_SelectedRowValue] = 26, “foregroundNeutralTertiaryAlt”,
    [Measure_SelectedRowValue] = 27, “foregroundSelected”,
    [Measure_SelectedRowValue] = 28, “foregroundButton”,
    [Measure_SelectedRowValue] = 29, “backgroundLight”,
    [Measure_SelectedRowValue] = 30, “backgroundNeutral”,
    [Measure_SelectedRowValue] = 31, “backgroundDark”,
    [Measure_SelectedRowValue] = 32, “hyperlink”,
    [Measure_SelectedRowValue] = 33, “visitedHyperlink”,
    [Measure_SelectedRowValue] = 34, “shapeStroke”,
    [Measure_SelectedRowValue] = 35, “disabledText”,
    [Measure_SelectedRowValue] = 36, “mapPushpin”,
    [Measure_SelectedRowValue] = 37, “–GUESSES BELOW–“,
    [Measure_SelectedRowValue] = 38, “minColor”,
    [Measure_SelectedRowValue] = 39, “midColor”,
    [Measure_SelectedRowValue] = 40, “maxColor”,
    [Measure_SelectedRowValue] = 41, “neutral”,
    [Measure_SelectedRowValue] = 42, “bad”,
    [Measure_SelectedRowValue] = 43, “good”,
    [Measure_SelectedRowValue] = 44, “nullColor”,
    [Measure_SelectedRowValue] = 45, “null”,
    [Measure_SelectedRowValue] = 46, “negativeColor”,
    [Measure_SelectedRowValue] = 47, “neutralColor”,
    [Measure_SelectedRowValue] = 48, “positiveColor”,
    [Measure_SelectedRowValue] = 49, “badColor”,
    [Measure_SelectedRowValue] = 50, “goodColor”,
    [Measure_SelectedRowValue] = 51, “neutralColor”,
    [Measure_SelectedRowValue] = 52, “startColor”,
    [Measure_SelectedRowValue] = 53, “endColor”,
    [Measure_SelectedRowValue] = 54, “0”,
    [Measure_SelectedRowValue] = 55, “1”,
    [Measure_SelectedRowValue] = 56, “pbiColor2”,
    [Measure_SelectedRowValue] = 57, “one”,
    [Measure_SelectedRowValue] = 58, “two”,
    [Measure_SelectedRowValue] = 59, “c1”,
    [Measure_SelectedRowValue] = 60, “positive”,
    [Measure_SelectedRowValue] = 61, “negative”,
    [Measure_SelectedRowValue] = 62, “max”,
    [Measure_SelectedRowValue] = 63, “null”,
    [Measure_SelectedRowValue] = 64, “min”,
    [Measure_SelectedRowValue] = 65, “start”,
    [Measure_SelectedRowValue] = 66, “end”,
    [Measure_SelectedRowValue] = 67, “themeColor1”,
    [Measure_SelectedRowValue] = 68, “theme1”,
    [Measure_SelectedRowValue] = 69, “themecolor1”,
    [Measure_SelectedRowValue] = 70, “colorValue1”,
    [Measure_SelectedRowValue] = 71, “color8”,
    [Measure_SelectedRowValue] = 72, “ThemeDataColor”,
    [Measure_SelectedRowValue] = 73, “themeDataColor”,
    [Measure_SelectedRowValue] = 74, “ThemeDataColor8”,
    [Measure_SelectedRowValue] = 75, “themeDataColor8”,
    [Measure_SelectedRowValue] = 76, “ColorId”,
    [Measure_SelectedRowValue] = 77, “ColorId8”,
    [Measure_SelectedRowValue] = 78, “colorId”,
    [Measure_SelectedRowValue] = 79, “colorId8”,
    [Measure_SelectedRowValue] = 80, “dataColors.8”,
    [Measure_SelectedRowValue] = 81, “val1”,
    [Measure_SelectedRowValue] = 82, “dataColors[‘8’]”,
    [Measure_SelectedRowValue] = 83, “items”,
    [Measure_SelectedRowValue] = 84, “items1”,
    [Measure_SelectedRowValue] = 85, “items[8]”,
    [Measure_SelectedRowValue] = 86, “items[‘8’]”,
    [Measure_SelectedRowValue] = 87, “Theme1”,
    [Measure_SelectedRowValue] = 88, “start”,
    [Measure_SelectedRowValue] = 89, “end”,
    [Measure_SelectedRowValue] = 90, “Theme color 8”,
    [Measure_SelectedRowValue] = 91, “ruleColorStop”,
    [Measure_SelectedRowValue] = 92, “calloutcalloutColor”,
    [Measure_SelectedRowValue] = 93, “titleColor”,
    [Measure_SelectedRowValue] = 94, “headerColor”,
    [Measure_SelectedRowValue] = 95, “label”,
    [Measure_SelectedRowValue] = 96, “labelColor”,
    [Measure_SelectedRowValue] = 97, “downArrow”,
    [Measure_SelectedRowValue] = 98, “Primary 8”,
    [Measure_SelectedRowValue] = 99, “Color 8”,
    [Measure_SelectedRowValue] = 100, “color8”,
    [Measure_SelectedRowValue] >= 100, “”,
    “”
    )

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.