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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
kiuhgfkijHFIOuw
New Member

PowerBI color mesure does not work

 

ColorMeasure =
SWITCH(
    TRUE(),
    MAX(Rohdaten_E1[Pakete LZ nicht erreicht LZ E2E]) <= 20, "#D3D3D3",
    AND(MAX(Rohdaten_E1[Pakete LZ nicht erreicht LZ E2E]) > 20, MAX(Rohdaten_E1[Pakete LZ nicht erreicht LZ E2E]) <= 50), "#FFDC00",
    "#B40014"
)

 

Screenshot 2025-05-23 134448.png

2 ACCEPTED SOLUTIONS
ABD128
Resolver I
Resolver I

Hi @kiuhgfkijHFIOuw 

 

Could you please explain the issue clearly? What is the visual you are using and what is the error you are getting ?

View solution in original post

v-karpurapud
Community Support
Community Support

Hi @kiuhgfkijHFIOuw 

 

Welcome to the Microsoft Fabric Community Forum.

Regarding the issue with your color measure not working as expected in Power BI,while I’m not fully aware of the exact structure of your dataset, I’ve created a sample .pbix file to demonstrate one possible solution


 

The issue arises from the use of the AND() function inside a SWITCH(TRUE(), ...) statement. In DAX, while AND() returns a Boolean value, its use inside SWITCH(TRUE(), ...) can lead to unexpected behavior, especially when combining multiple conditions that evaluate values from a measure or column.

To resolve this, update DAX measure as follows: 

ColorMeasure =
VAR Value = MAX(Rohdaten_E1[Pakete LZ nicht erreicht LZ E2E])
RETURN
    SWITCH(
        TRUE(),
        Value <= 20, "#D3D3D3",       
        Value <= 50, "#FFDC00",       
        "#B40014"                     
    )


I have attached a .PBIX, please take a moment to review them and see if this solution aligns with your requirements.

 If this doesn’t fully meet your needs, could you kindly share a sample of your data and more detailed context? That would help us provide a more accurate solution. If you have any additional questions or require further assistance with implementing this measure in your visuals, please do not hesitate to follow up here.

 

If this response resolves your query, kindly mark it as Accepted Solution to help other community members. A Kudos is also appreciated if you found the response helpful.

 

Thank you!



 

View solution in original post

4 REPLIES 4
kiuhgfkijHFIOuw
New Member

Thanky you!

v-karpurapud
Community Support
Community Support

Hi @kiuhgfkijHFIOuw 

 

Welcome to the Microsoft Fabric Community Forum.

Regarding the issue with your color measure not working as expected in Power BI,while I’m not fully aware of the exact structure of your dataset, I’ve created a sample .pbix file to demonstrate one possible solution


 

The issue arises from the use of the AND() function inside a SWITCH(TRUE(), ...) statement. In DAX, while AND() returns a Boolean value, its use inside SWITCH(TRUE(), ...) can lead to unexpected behavior, especially when combining multiple conditions that evaluate values from a measure or column.

To resolve this, update DAX measure as follows: 

ColorMeasure =
VAR Value = MAX(Rohdaten_E1[Pakete LZ nicht erreicht LZ E2E])
RETURN
    SWITCH(
        TRUE(),
        Value <= 20, "#D3D3D3",       
        Value <= 50, "#FFDC00",       
        "#B40014"                     
    )


I have attached a .PBIX, please take a moment to review them and see if this solution aligns with your requirements.

 If this doesn’t fully meet your needs, could you kindly share a sample of your data and more detailed context? That would help us provide a more accurate solution. If you have any additional questions or require further assistance with implementing this measure in your visuals, please do not hesitate to follow up here.

 

If this response resolves your query, kindly mark it as Accepted Solution to help other community members. A Kudos is also appreciated if you found the response helpful.

 

Thank you!



 

Thank you for your time

ABD128
Resolver I
Resolver I

Hi @kiuhgfkijHFIOuw 

 

Could you please explain the issue clearly? What is the visual you are using and what is the error you are getting ?

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors