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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sameergupta60
Helper IV
Helper IV

Conditional formatting

Dear Team,

 

I need help with conditional formatting.

 

BWNEWBICFR1 = VAR _maxrcc = MAXX(SUMMARIZE('L1','L1'[Code33],"rcc",[RCCCount]),[rcc])
VAR _colour = IF([RCCCount]-7>[BWcount]&&[RCCCount]=_maxrcc,"Amber")return _colour 
 
this condition is working but I have to add one more conditional in this measure 
VAR _colour = IF([RCCCount]-6>[BWcount]&&[RCCCount]=_maxrcc,"Green"), 
if both conditional is not fulfilled then it is red color.
 
 
Please guide.
 
 
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@sameergupta60 , Try like

 

BWNEWBICFR1 = VAR _maxrcc = MAXX(SUMMARIZE('L1','L1'[Code33],"rcc",[RCCCount]),[rcc])
VAR _colour = Switch(True() ,
[RCCCount]-6>[BWcount]&&[RCCCount]=_maxrcc,"Green",
[RCCCount]-7>[BWcount]&&[RCCCount]=_maxrcc,"Amber",
"Red"

) return _colour

 

or

 

BWNEWBICFR1 = VAR _maxrcc = MAXX(SUMMARIZE('L1','L1'[Code33],"rcc",[RCCCount]),[rcc])
VAR _colour = Switch(True() ,

[RCCCount]-7>[BWcount]&&[RCCCount]=_maxrcc,"Amber",
[RCCCount]-6>[BWcount]&&[RCCCount]=_maxrcc,"Green",

"Red"

) return _colour

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

View solution in original post

Hi @sameergupta60 ,

 

When you use switch(), you should give it a range. SWITCH will return the result when the condition holds, regardless of whether the condition that follows is true or false

 

So:

 

BWNEWBICFR1 =
VAR _maxrcc =
    MAXX ( SUMMARIZE ( 'L1', 'L1'[Code33], "rcc", [RCCCount] ), [rcc] )
RETURN
    SWITCH (
        TRUE (),
        [RCCCount] - [BWcount] > 7
            && [RCCCount] = _maxrcc, "Orange",
        [RCCCount] - [BWcount] = 7
            && [RCCCount] = _maxrcc, "green",
        "red"
    )

 

 

Best Regards

Community Support Team _ chenwu zhu

 

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

5 REPLIES 5
amitchandak
Super User
Super User

@sameergupta60 , Try like

 

BWNEWBICFR1 = VAR _maxrcc = MAXX(SUMMARIZE('L1','L1'[Code33],"rcc",[RCCCount]),[rcc])
VAR _colour = Switch(True() ,
[RCCCount]-6>[BWcount]&&[RCCCount]=_maxrcc,"Green",
[RCCCount]-7>[BWcount]&&[RCCCount]=_maxrcc,"Amber",
"Red"

) return _colour

 

or

 

BWNEWBICFR1 = VAR _maxrcc = MAXX(SUMMARIZE('L1','L1'[Code33],"rcc",[RCCCount]),[rcc])
VAR _colour = Switch(True() ,

[RCCCount]-7>[BWcount]&&[RCCCount]=_maxrcc,"Amber",
[RCCCount]-6>[BWcount]&&[RCCCount]=_maxrcc,"Green",

"Red"

) return _colour

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

BWNEWBICFR1 = VAR _maxrcc = MAXX(SUMMARIZE('L1','L1'[Code33],"rcc",[RCCCount]),[rcc])
VAR _colour = Switch(True() ,
 
[RCCCount]-7>[BWcount]&&[RCCCount]=_maxrcc,"Red",
[RCCCount]-6>[BWcount]&&[RCCCount]=_maxrcc,"Orange",
[RCCCount]-5>[BWcount]&&[RCCCount]=_maxrcc,"Orange",

 

"Green"
return _colour



Thanks for your support we have to add one conditional formatting in the existing 

measure that 

[RCCCount]="T01"-80>[BWcount]&&[RCCCount]+_maxrcc,"Yellow",

 

if my terrace finish &  blockwork is not started with more than 80-day gaps it should be yellow

Dear Sir,

 

we have to add three conditional formatting.

 

1) if my RCC is on 20 floors then blockwork should be on 13 floors means 7 floors less than it has to Orange color

2)if my RCC is on 20 floors then blockwork should be on 14 floors means 6 floors less than it has to green color

 

3)if both conditional is not fulfilled then it should be RED.

 

 

Hi @sameergupta60 ,

 

When you use switch(), you should give it a range. SWITCH will return the result when the condition holds, regardless of whether the condition that follows is true or false

 

So:

 

BWNEWBICFR1 =
VAR _maxrcc =
    MAXX ( SUMMARIZE ( 'L1', 'L1'[Code33], "rcc", [RCCCount] ), [rcc] )
RETURN
    SWITCH (
        TRUE (),
        [RCCCount] - [BWcount] > 7
            && [RCCCount] = _maxrcc, "Orange",
        [RCCCount] - [BWcount] = 7
            && [RCCCount] = _maxrcc, "green",
        "red"
    )

 

 

Best Regards

Community Support Team _ chenwu zhu

 

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

BWNEWBICFR1 = VAR _maxrcc = MAXX(SUMMARIZE('L1','L1'[Code33],"rcc",[RCCCount]),[rcc])
VAR _colour = Switch(True() ,
 
[RCCCount]-7>[BWcount]&&[RCCCount]=_maxrcc,"Red",
[RCCCount]-6>[BWcount]&&[RCCCount]=_maxrcc,"Orange",
[RCCCount]-5>[BWcount]&&[RCCCount]=_maxrcc,"Orange",

 

"Green"
) return _colour



Thanks for your support we have to add one conditional formatting in the existing 

measure that 

[RCCCount]="T01"-80>[BWcount]&&[RCCCount]+_maxrcc,"Yellow",

 

if my terrace finish &  blockwork is not started with more than 80-day gaps it should be yellow

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.