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

Nested if for conditional colorig

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.
 
1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

According to the formula you provided, if you want to use a judgment condition like [UOM Type_measure] = "min" in the filter condition, you need to rewrite it by the all function.

I did a test reference as follows:

M = 
VAR a = [M_min] = "min"
RETURN
    CALCULATE ( MAX ( 'Table'[Column1] ), FILTER(ALL('Table'),a))

vhenrykmstf_0-1659429612905.png

vhenrykmstf_1-1659429632595.png


If the problem is still not resolved, please provide detailed error information and test data. Looking forward to your reply.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

According to the formula you provided, if you want to use a judgment condition like [UOM Type_measure] = "min" in the filter condition, you need to rewrite it by the all function.

I did a test reference as follows:

M = 
VAR a = [M_min] = "min"
RETURN
    CALCULATE ( MAX ( 'Table'[Column1] ), FILTER(ALL('Table'),a))

vhenrykmstf_0-1659429612905.png

vhenrykmstf_1-1659429632595.png


If the problem is still not resolved, please provide detailed error information and test data. Looking forward to your reply.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

I want to say if that measure/column value is equal to "min" then name that as var rule_with_min .

amitchandak
Super User
Super User

@Anonymous , First all this does not seem right to me

var rule_with_min = [UOM Type_measure] = "min"

 

 

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