Skip to main content

Power BI

New

Function to reference theme colors from DAX

Vote (1) Share
Andy Clapham's profile image

Andy Clapham on 25 Sep 2023 15:44:09

It would be very useful to be able to reference theme colors from DAX for use in measures that provide a custom color to a visual.

So that if the theme is changed, no additional work is needed to edit DAX formulas that use colors from the theme.


This could be similar to the js colorPalette API for visuals - e.g.

COLORPALETTE(key) returns the hex color code from the current palette, with the standard keys from ISandboxExtendedColorPalette in visuals-api.d.ts


e.g. I would like a particular background colour for a slicer if there is a selection, but to use the theme colour if not.

I would be able do this using a measure for the the background colour with something like this:


MyField_SlicerBackground = IF(ISFILTERED(MyField), COLORPALETTE("selection"), COLORPALETTE("backgroundNeutral"))