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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
szymonswiezyfg
Frequent Visitor

color change based on applied filter

Hi, I would like to change the color formatting in columns based on the selected range on the filter. For example, if I select the range from 2005 to 2010, I want the color to change to blue, while the rest remains gray. I've written various formulas, but I keep getting an error: "DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values."

DAX:
color = SWITCH( TRUE(), AND( VALUE('Calendar'[Date]) >= MIN('Calendar'[Date]), VALUE('Calendar'[Date]) <= MAX('Calendar'[Date]) ), "blue", "gray" )

szymonswiezyfg_1-1707732060116.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@szymonswiezyfg , Make sure in such case slicer is coming from disconnected Date Table

 

//Date1 is independent Date table, Calendar is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = minx(allselected(Date1),Date1[Date])
return
if( max('Calendar'[Date]) >=_min && max('Calendar'[Date]) <=_max, "blue", "gray" )

 

On my Data

 

amitchandak_0-1707740098794.png

 

 

amitchandak_1-1707740132860.png

 

Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9af...
Power BI Field Parameters- Measure Slicer and Axis/Dimension slicer: https://youtu.be/lqF3Wa1FllE
Switch TOPN with Field Parameters: https://amitchandak.medium.com/switch-topn-with-field-parameters-299a0ae3725f
Field Parameters- Conditional Formatting
: https://amitchandak.medium.com/field-parameters-conditional-formatting-517aacc23fdf
Power BI Field Parameters, Keep Axis Sort intact| Always Sort on X/Categorial Axis: https://youtu.be/GfBrB6czByw

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
szymonswiezyfg
Frequent Visitor

Thank you very much, it works. Is it possible for such a functioning slicer to also affect filtering in other visualizations in the report? If so, how? In this case, I would like this type of slicer to filter colors on the map.

amitchandak
Super User
Super User

@szymonswiezyfg , Make sure in such case slicer is coming from disconnected Date Table

 

//Date1 is independent Date table, Calendar is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = minx(allselected(Date1),Date1[Date])
return
if( max('Calendar'[Date]) >=_min && max('Calendar'[Date]) <=_max, "blue", "gray" )

 

On my Data

 

amitchandak_0-1707740098794.png

 

 

amitchandak_1-1707740132860.png

 

Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9af...
Power BI Field Parameters- Measure Slicer and Axis/Dimension slicer: https://youtu.be/lqF3Wa1FllE
Switch TOPN with Field Parameters: https://amitchandak.medium.com/switch-topn-with-field-parameters-299a0ae3725f
Field Parameters- Conditional Formatting
: https://amitchandak.medium.com/field-parameters-conditional-formatting-517aacc23fdf
Power BI Field Parameters, Keep Axis Sort intact| Always Sort on X/Categorial Axis: https://youtu.be/GfBrB6czByw

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.