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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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

5 REPLIES 5
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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.