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
Saxon10
Post Prodigy
Post Prodigy

Conditional formatting for Variable

 

I have the following columns are Id, Code, Result1, Result2, Result1 colour code and Result colour code in data table.

 

For Result1 and Resul2 created slicer table for switch the Results in visual and the same way created measure for value columns in matrix table .

 

Data:

IDCodeResult1Result2Result colour codeResult2 colour code
1SAWinId1GreenGreen
1SAWinId1GreenGreen
1SBWinId1GreenGreen
1SCWinId1GreenGreen
1SDWinId1GreenGreen
1SDWinId1GreenGreen
2SALossId2RedRed
2SBLossId2RedRed
2SCLossId2RedRed
2SDLossId2RedRed
3SALossId3RedOrange
3SALossId3RedOrange
4SAWinId4GreenYellow
4SAWinId4GreenYellow
5SAWinId5GreenPurple
5SBWinId5GreenPurple
6SCLossId6RedBlue
6SDLossId6RedBlue

 

AlexisOlson helped for slicer and measure

 

Slicer = DATATABLE ( "Result", STRING, {{"Result 1"}, {"Result 2"}} )
 
VarResult =
SWITCH (
SELECTEDVALUE ( Slicer[Result] ),
"Result 1", SELECTEDVALUE ( REPORT[Result1] ),
"Result 2", SELECTEDVALUE ( REPORT[Result2] ),
SELECTEDVALUE ( REPORT[Result1] ) & "-" & SELECTEDVALUE ( REPORT[Result2] )
)

 

If I selected the Result1 status in slicer table then it will reflect Result1 status and row/columns only and the same thing for Result2.

 

Now my question is how can I apply the conditional according to the result.

 

Saxon10_0-1636497333452.png

Measure:

 

Saxon10_1-1636498081919.png

 

Slicer

Saxon10_2-1636498112065.png

 

PBI file attached.

https://www.dropbox.com/s/rpesne9daxq45j6/Materix%20multiple%20visual%20on%20value%20column.pbix?dl=...

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Define a similar color measure.

VarColor = 
SWITCH (
    SELECTEDVALUE ( Slicer[Result] ),
    "Result 1", SELECTEDVALUE ( REPORT[Result colour code] ),
    "Result 2", SELECTEDVALUE ( REPORT[Result2 colour code] )
)

 

Then use that in the conditional formatting.

AlexisOlson_0-1636501524694.png

 

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

Define a similar color measure.

VarColor = 
SWITCH (
    SELECTEDVALUE ( Slicer[Result] ),
    "Result 1", SELECTEDVALUE ( REPORT[Result colour code] ),
    "Result 2", SELECTEDVALUE ( REPORT[Result2 colour code] )
)

 

Then use that in the conditional formatting.

AlexisOlson_0-1636501524694.png

 

Hi. Thanks for your reply and sorry for the late response.

Your solution is working well. 

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.