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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
kault
Helper II
Helper II

DAX Help - Additional "If" criteria

I have a measure that shows values as red (#efb5b9) if Utilization Rate is over 80% (varLevel2).
How can I update this DAX to also show:
  • If utilization rate is between 70% - 80%, then show yellow #f0e199
  • If Utilization Rate is less than 70%, then show green #d0ef9e

 

This is the current measure DAX that shows only the red:

conditonalformatting =
    VAR varLevel2 = ( 80 / 100 )
    VAR varLevel1 = ( 35 / 1000 )
    RETURN
        IF (
            ISINSCOPE ('Projector Deployment Report Current and Planned'[Stage]),
            BLANK (),
            IF (
                ISINSCOPE ('Projector Deployment Report Current and Planned'[Resource])
                    && ([Utilization Rate]) > varLevel2,
                "#efb5b9",
                IF (
                    ISINSCOPE ('Resource Assigned Practice Group'[Role])
                        && ([Utilization Rate]) > varLevel1,
                    "#fffff"
                )
            )
        )
1 ACCEPTED SOLUTION
marcelsmaglhaes
Super User
Super User

Hey @kault ,

You can use the SWITCH function to do that. Like something:

conditonalformatting =
    VAR varLevel2 = ( 80 / 100 )
    VAR varLevel1 = ( 35 / 1000 )
    RETURN
     SWITCH (
                         TRUE(),
           ISINSCOPE ('Projector Deployment Report Current and Planned'[Stage]), BLANK (),
           ISINSCOPE ('Projector Deployment Report Current and Planned'[Resource]  &&
                               ([Utilization Rate]) > varLevel2"#efb5b9",
           
ISINSCOPE ('Projector Deployment Report Current and Planned'[Resource]  &&
                              ( ([Utilization Rate]) > 0.7 && ([Utilization Rate]) < 0.8), "#f0e199",
 ISINSCOPE ('Projector Deployment Report Current and Planned'[Resource])   &&
                              ( ([Utilization Rate]) < 0.7, "#d0ef9e", 
 "#fffff"
)

Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



View solution in original post

4 REPLIES 4
marcelsmaglhaes
Super User
Super User

Hey @kault ,

You can use the SWITCH function to do that. Like something:

conditonalformatting =
    VAR varLevel2 = ( 80 / 100 )
    VAR varLevel1 = ( 35 / 1000 )
    RETURN
     SWITCH (
                         TRUE(),
           ISINSCOPE ('Projector Deployment Report Current and Planned'[Stage]), BLANK (),
           ISINSCOPE ('Projector Deployment Report Current and Planned'[Resource]  &&
                               ([Utilization Rate]) > varLevel2"#efb5b9",
           
ISINSCOPE ('Projector Deployment Report Current and Planned'[Resource]  &&
                              ( ([Utilization Rate]) > 0.7 && ([Utilization Rate]) < 0.8), "#f0e199",
 ISINSCOPE ('Projector Deployment Report Current and Planned'[Resource])   &&
                              ( ([Utilization Rate]) < 0.7, "#d0ef9e", 
 "#fffff"
)

Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



Thank you. This gives me an error message. Do you know what is causing the error?

 

Screenshot 2023-02-23 170634.png

 

Yes, has a parenthesis left over in the last line: Try copying and pasting this part of the code to fix:

...............
 ISINSCOPE ('Projector Deployment Report Current and Planned'[Resource])   &&
                              ([Utilization Rate]) < 0.7, "#d0ef9e",
 "#ffffff"
)

Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



THANK YOU!!! I have spent hours trying to figure this out. I appreciate it.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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