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
Anonymous
Not applicable

Nested if for conditional coloring

Dear Community,

 

I m trying to write a measure that will later be used to color the matrix cell elements with conditional coloring.  

I have min and max in my data and depending on it the rule is like versa versa.

 

The problem is that the second part of the measure works, when the fileds is not equal to min. While the first part of tthe measure when the field i equal to min, doesn't work.

 

Here is my measure:

 

Card color3 =
 
var rule_with_min = [UOM Type_measure] = "min"

var color_min =
CALCULATE( IF(AVERAGE('alr ALR_PCI_SNIFFER_v2_DAILY_LOGS'[Current_Value])<
MAX('alr ALR_PCI_SNIFFER_v2_DAILY_LOGS'[Threshold]) && rule_with_min, 1, IF(AVERAGE('alr ALR_PCI_SNIFFER_v2_DAILY_LOGS'[Current_Value])> MAX('alr ALR_PCI_SNIFFER_v2_DAILY_LOGS'[Threshold]) && rule_with_min, 0, 2)))

var remaining_color =
CALCULATE( IF(AVERAGE('alr ALR_PCI_SNIFFER_v2_DAILY_LOGS'[Current_Value])>
MAX('alr ALR_PCI_SNIFFER_v2_DAILY_LOGS'[Threshold]), IF([UOM Type_measure] <> "min", 1, IF(AVERAGE('alr ALR_PCI_SNIFFER_v2_DAILY_LOGS'[Current_Value])< MAX('alr ALR_PCI_SNIFFER_v2_DAILY_LOGS'[Threshold]), IF([UOM Type_measure] <> "min", 0, IF([UOM Type_measure] <> "min", 2))))))

Return
IF(rule_with_min, color_min, remaining_color)
 
 
I would appreciate t highly if you could help me tackle this issue.
 
3 REPLIES 3
Anonymous
Not applicable

Basically I have 2 cases:

1. if (average(curret_value) < threshold, then 1, 2)

2. if (average(curret_value) > threshold, then 1, 2)

I want to write these 2 conditions using  variable in DAX.

Anonymous
Not applicable

My 2 conditions:

1. if (average(curret_value) < threshold, then 1, 2)

2. if (average(curret_value) > threshold, then 1, 2)

 

So, if [UOM Type_measure] = "min", use condition 1, else use condition 2. Hope this makes my question more clear.

amitchandak
Super User
Super User

@Anonymous ,The information you have provided is not making the problem clear to me. Can you please explain with an example.
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Appreciate your Kudos.



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
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.