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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ajay_gajree
Helper I
Helper I

DAX Conditional Formatting

Tree Map Colour Formatting = 
VAR NewZealand = IF(SELECTEDVALUE('Team Stats'[Team]) = "New Zealand", True, False)
VAR France = IF(SELECTEDVALUE('Team Stats'[Team]) = "France", True, False)

RETURN

SWITCH(
TRUE(),
NewZealand , "#000000",
France, "#0000C0")

 

Hi 

 

I have the above DAX that will colour my chart appropriately when either New Zealand France are selected in the Country Slicer

But I want to colour the chart regardless of the slicer selection

 

Can anyone suggest an approach?

 

1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

If you want to apply conditional formatting based on the team regardless of the slicer selection, you can modify your DAX code. Instead of relying on the SELECTEDVALUE function, you can directly compare the Team column with the desired team names. Here's an example:

 

Tree Map Colour Formatting =
VAR CurrentTeam = 'Team Stats'[Team]

RETURN
SWITCH(
TRUE(),
CurrentTeam = "New Zealand", "#000000",
CurrentTeam = "France", "#0000C0",
// Add more conditions as needed
"#FFFFFF" // Default color if none of the conditions are met
)

 

In this example, the CurrentTeam variable captures the currently selected team from the 'Team Stats' table. The SWITCH function then checks the value of CurrentTeam against the desired teams ("New Zealand", "France") and assigns the corresponding color. You can add more conditions as needed.

The last line with #FFFFFF is the default color in case none of the conditions are met.

This modification should apply the conditional formatting based on the team regardless of the slicer selection.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

View solution in original post

1 REPLY 1
123abc
Community Champion
Community Champion

If you want to apply conditional formatting based on the team regardless of the slicer selection, you can modify your DAX code. Instead of relying on the SELECTEDVALUE function, you can directly compare the Team column with the desired team names. Here's an example:

 

Tree Map Colour Formatting =
VAR CurrentTeam = 'Team Stats'[Team]

RETURN
SWITCH(
TRUE(),
CurrentTeam = "New Zealand", "#000000",
CurrentTeam = "France", "#0000C0",
// Add more conditions as needed
"#FFFFFF" // Default color if none of the conditions are met
)

 

In this example, the CurrentTeam variable captures the currently selected team from the 'Team Stats' table. The SWITCH function then checks the value of CurrentTeam against the desired teams ("New Zealand", "France") and assigns the corresponding color. You can add more conditions as needed.

The last line with #FFFFFF is the default color in case none of the conditions are met.

This modification should apply the conditional formatting based on the team regardless of the slicer selection.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.