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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.