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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Conditional Formatting of Visuals

I have 2 visuals I am trying to add conditional formatting to.  Visual 2 has conditional formatting based on the Region.  The data set has a column called Region, and a calculated column called Color using this formula:

 

Color = SWITCH(TRUE(),'DPM'[Region]="EMEA","#0061ff",DPM[Region]="APAC","#184489",'DPM'[Region]="Americas","#99c0ff","#979da8")

 

Conditional formatting is then applied to Visual 2 so now Americas = Color 1 (#99c0ff), APAC = Color 2 (#184489) and EMEA = Color 3 (#0061ff).

 

Next I want to also apply the same conditional formatting to Visual 1, except that if no Region is selected, it defaults to Color 4 (#979da8).  I can't seem to make this work.  By default Visual 2 is display either the First or Last in the "Color" column.  Any help would be greatly appreciated!

 

Thanks,

Steve

 

Steveimages2.pngimages1.png

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

To create a measure as below and make the the visual formatted by the filed.

 

Color = var countr = CALCULATE(COUNT(DPM[Region]),ALLSELECTED(DPM))
var no = IF(countr=3,"#979da8")
var re = IF(MAX('DPM'[Region])="EMEA","#0061ff",IF(MAX(DPM[Region])="APAC","#184489",IF(MAX('DPM'[Region])="Americas","#99c0ff")))
return
IF(ISFILTERED(DPM[Region]),re,no)

Capture.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

To create a measure as below and make the the visual formatted by the filed.

 

Color = var countr = CALCULATE(COUNT(DPM[Region]),ALLSELECTED(DPM))
var no = IF(countr=3,"#979da8")
var re = IF(MAX('DPM'[Region])="EMEA","#0061ff",IF(MAX(DPM[Region])="APAC","#184489",IF(MAX('DPM'[Region])="Americas","#99c0ff")))
return
IF(ISFILTERED(DPM[Region]),re,no)

Capture.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Brilliant!  Works perfectly.  Thanks Frank!

Anonymous
Not applicable

One minor update: I modified your calculated measure slightly to use HASONEVALUE instead of ISFILTERED in the IF statement.  That way if the user selects multiple regions, the formatting works as intended.

 

Thanks again.

 

Color = var countr = CALCULATE(COUNT(DPM[Region]),ALLSELECTED(DPM))
var no = IF(countr=3,"#979da8")
var re = IF(MAX('DPM'[Region])="EMEA","#0061ff",IF(MAX(DPM[Region])="APAC","#184489",IF(MAX('DPM'[Region])="Americas","#99c0ff")))
return
IF(HASONEVALUE(DPM[Region]),re,no)

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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