Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
TrevorC
Advocate I
Advocate I

Reference theme dataColors with DAX

As a developer I want to be able to reference data colour hex codes via Dax. I can reference Divergent and Sentent colors but nothing else. 

The reason I want to do this is to help me create templates that have page titles and use colors from the theme. What would be better would be to add three layers of color codes that can be used for branding of the reports. 

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

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.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

7 REPLIES 7
TrevorC
Advocate I
Advocate I

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.

 

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.

 

KNP
Super User
Super User

Hi @TrevorC,

 

As others have mentioned, not all colours are exposed currently.

Best practice at the moment would be to have a colour table that can be imported into your models and reference HEX/RGBA colours from there. It allows for use in conditional formatting, etc., and as long as your theme colours are constant, it is easy to match your theme.

Bonus points for creating an opposing text colour, taking into account contrast ratios.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!
v-sshirivolu
Community Support
Community Support

Hi  @TrevorC ,
At this time, Power BI does not provide direct access to all theme color hex codes (dataColors) within DAX. You may wish to submit this as a feature request or upvote an existing idea using the link provided.
Fabric Ideas - Microsoft Fabric Community

As a workaround, you can create a disconnected color table with category–color mappings and use a measure like below for conditional formatting:
Color Code =
LOOKUPVALUE(
ColorTable[ColorHex],
ColorTable[Category],
SELECTEDVALUE(Data[Category])
)

Then apply this measure in the Field value option under conditional formatting to get theme based colors.

 

Hi @TrevorC ,

I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.

 

Hi @TrevorC ,

I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you

 

rajendraongole1
Super User
Super User

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.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.