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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply

Switch colour formatting via user choice

I have a colour formatting switch like this:

 

LateColor = 
var col = SELECTEDVALUE(DimLate[Lateness Group])
RETURN
SWITCH(
        TRUE(),
            col = "Early", "#2c7bb6",
            col = "On Time", "#2c7bb6",
            col = "Late", "#c80651",
            col = "No date", "#000000",
            "#000000"
)

 

It works, showing blue for early and on-time, and showing red for late

 

However, the great and almighty powers-that-be want to see red & green in their dashboards (antiquated, I know).  As I know we have red-green colourblind people in our company, my thinking was to offer both options

 

What is the best way that I can add a switch measure so that my users can choose between "Traditional"(red/green) vs "Inclusive" (red/blue) colours by way of a radio button?

 

1 ACCEPTED SOLUTION
djurecicK2
Super User
Super User

Hi @dapperscavenger ,

 You can create a disconnected table with "Traditional" and "Inclusive" as rows. Use the field from that table in your slicer. Use SelectedValue to get the selected option. Then use If statement .

Something like this:

 

Measure= 

var _SelectedColor= SELECTEDVALUE(DisconnectedTableName[FieldName])

return

If(_SelectedColor="Traditional", Do the red/green stuff here, Do the red/blue stuff here) 

 

View solution in original post

2 REPLIES 2
djurecicK2
Super User
Super User

Hi @dapperscavenger ,

 You can create a disconnected table with "Traditional" and "Inclusive" as rows. Use the field from that table in your slicer. Use SelectedValue to get the selected option. Then use If statement .

Something like this:

 

Measure= 

var _SelectedColor= SELECTEDVALUE(DisconnectedTableName[FieldName])

return

If(_SelectedColor="Traditional", Do the red/green stuff here, Do the red/blue stuff here) 

 

Thanks!  This got me started in the right direction

 

I created a table containing the hex codes, so that in the future if I need to change the colour schemes I can do it for all the formulas in one go by just updating the table

 

(These are just test hex codes btw):

Screenshot 2022-12-07 233831.png

 

Added slicer to the visuals with single select only, for the View field

Screenshot 2022-12-07 234041.png

 

 

 

 

And then called the hex codes with below measure:

Measure = 
var _ColPos = CALCULATE(MAX(DimColour[Positive]),FILTER(DimColour,SELECTEDVALUE(DimColour[View]) = DimColour[View]))

var _ColNeg = CALCULATE(MAX(DimColour[Negative]),FILTER(DimColour,SELECTEDVALUE(DimColour[View]) = DimColour[View]))

return

if( [MyOtherMeasure] <=0 ,_ColPos,_ColNeg))

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors