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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
JoseDavidM
Helper I
Helper I

Dax for Conditional Formatting

Hi, i'm looking for a way to apply color formatting to a field based on another field. my idea is to apply a specific color to the field Codigo_de_Ruta[Hacia] based on the action performed on the field Codigo_de_Ruta[De], the idea is that if the [DE] (Posicion actual) field is selected the [HACIA] (1. Posible Siguiente Paso) field must be highlighted. (images below):

JoseDavidM_0-1611848733752.png

JoseDavidM_1-1611848759826.png

thank you for your answer

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @JoseDavidM 

 

Sorry I don't understand your expected result clearly. You want to highlight a slicer according to the selected value of the other slicer? Or something else? These two fields are from the same table, if you select a value in the left slicer, the slicer on the right side will be filtered to contain values which are related to the selected value in the left slicer. Do you mean you want to highlight these filtered values?

 

You can change the background color of the slicer conditionally with a measure like:

Color = SWITCH(SELECTEDVALUE('Codigo_de_Ruta'[De]),"Value A","Yellow","Value B","Green")

 

Kindly let me know if this helps.
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.

amitchandak
Super User
Super User

@JoseDavidM , You can create a color measure and use that in conditional formatting by using "Field value" option

 

refer for steps

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

 

Color Date =
var _min =minx(allselected(Date,Date[Year])
return
Switch( true(),
FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"lightgreen",
FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"blue",
"red")

if(FIRSTNONBLANK('Table'[Value],"true")= "true","green","red")

if(FIRSTNONBLANK(date[date],blank())= today(),"green","red")
if(max(date[date])= tofay(),"green","red")

 

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

sorry @amitchandak i was not able to adapt that code to my need, the fields [De] and [Hacia] in the table 'Codigo_de_Ruta' is a text field. i was looking to a way to get the current selected value in this object 

JoseDavidM_0-1611855916067.png

 

that contain the values of the field [De] in order to create the conditional format based on that

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors