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
bman6074
Helper I
Helper I

Conditional Formatting not working for all words in the column

I built a DAX to color wrods with int a matrix under "Values". When I setup the condition it colors some but not all. See screenshot. You see some background are colored and not colored even though its same words. It appears to work for some but not all. Why would this be? How can I fix?

 

Dax code 

Usage Risk Colors =
VAR Usage_Risk = SELECTEDVALUE('Key Table'[Usage_Risk])
RETURN
SWITCH(TRUE(),
Usage_Risk = "Unsupported/Not Allowed", "#E01920",
Usage_Risk = "Sunset", "#FAB131",
Usage_Risk = "Limited Use", "#FF5A00",
Usage_Risk = "preferred", "#7BBA00"
)

Power Bi Cond Color.png

1 ACCEPTED SOLUTION

I was able to resolve this problem by changing the visualization to a Table instead of a Matrix

View solution in original post

9 REPLIES 9
Mariusz
Community Champion
Community Champion

Hi @bman6074 

 

Change 

VAR Usage_Risk = SELECTEDVALUE('Key Table'[Usage_Risk])

to 

VAR Usage_Risk = MAX('Key Table'[Usage_Risk])

And see if that makes a difference

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

It makes a difference but not the right colors

Power Bi Cond Color2.png

Mariusz
Community Champion
Community Champion

Hi @bman6074 

 

SELECTEDVALUE was returning a second argument ( optional if multiple values occur ) witch in you case was not assigned and that's the reason for no color, now MAX is returning max value that obviously is not the one displayed in your table.

 

Is Usage risk in the screenshot table a Column or Measure?

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

I am still a bit New with Power bi and especially DAX coding. Not sure I totaly understand what your explaining. 

 

The Usage Risk is a column. I do have a Measure called Usage Risk Colors. 

power bi color3.png

 

I put the Usage Risk in values and then set a Backgorund condition using the measure. 

power bi color5.pngpower bi color4.png

Mariusz
Community Champion
Community Champion

Hi @bman6074,

 

Is Mitigation plan in the same table as Usage Risk?

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Yes Mitigation Plan is in the same table as Usage Risk along wtih the Measures for each

power bi color6.png

The odd thing I discoverd is when I setup a Filter for Usage_Risk and Filter it to one of the RIsks. It then colors the cell. 

You can see here EMA Correspondance shows no color wihtout filter. Once i filter it then shows correct color. and all are correctly colored for that risk. 

 

power bi color7.pngpower bi color8.png

 

if I select multiple in the filter it goes to back to the empty colors. Limited Use and Sunset seem to be the ones causing the problem. If I select Unsupported and Preferred together all are colored. I add in Limited User or Sunset I get empty colors for only Limited Use or Sunset. 

power bi 9.png

I was able to resolve this problem by changing the visualization to a Table instead of a Matrix

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.