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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.