Forum Discussion
Reference theme dataColors with DAX
- 10 months ago
Hi TrevorC - Power BI doesn’t currently expose all theme color hex codes directly to DAX, which limits dynamic formatting and templating potential.
Good Idea, : you can post it in below link:
Fabric Ideas - Microsoft Fabric Community
Hope this helps.
Hi there.
The folks at SQLBI.com have found a way to read some of the color codes.
Re-using visual formatting in and across Power BI reports - SQLBI
Combining the two approaches: referencing theme colors from DAX
Now, how do we use this with our themes? Well, it turns out that you can refer to theme colors from DAX. Like CSS color names, any top-level theme property that is a color can be used in a DAX expression. Examples include:
- Sentiment colors: “good”, “bad”, or “neutral”, which refer to positive, negative, and neutral sentiment theme colors, respectively.
- Diverging colors: “minColor”, “midColor”, or “maxColor”, which refer to min, middle, and max diverging theme colors, respectively.
- Container style colors: “foreground”, “background”, or “foregroundNeutralTertiary”, which refer to various elements as explained in the documentation for theme structural colors.
- Other structural colors: “tableAccent”, “null”, or “hyperlink”, which refer to the border of the table or matrix visual, empty colors in diverging conditional formatting, and the color of hyperlinks in tables and matrix visuals, respectively.
- v-sshirivolu6 months agoCommunity Support
Hi TrevorC ,
Thanks for sharing the SQLBI reference. This helps clarify the behavior. While Power BI still doesn't expose the full dataColors array to DAX, it does allow referencing certain top level theme colors using predefined names, such as sentiment, diverging, and structural colors. So only these specific theme color tokens are available in DAX today. If full control over colors is needed, a disconnected color table remains the recommended approach.