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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Easter-J
New Member

Help with a DAX Measure and Conditional Formatting

Hi! I am trying to write a DAX measure to use in a matrix to apply conditional formatting.

 

The row I want to highlight looks like this

EasterJ_0-1749589688504.png

 

I want to highlight the value 4.37 using the following measure

Measure =
IF (
    SELECTEDVALUE('Voluntary 2s Removed'[Id]) = "8.1.12" &&
    SELECTEDVALUE('Voluntary 2s Removed'[Rate]) >= 2.90,
    "Green",
    "White"
)

 

When I apply this measure the value 4.37 does not highlight, but if I flip the sign to (<= 2.90)  it highlights the value green. This seems backward to me because it is saying that the value to highlight should be less than or equal to 2.90. I only want to highlight if the value is greater than or equal to 2.90.  I could use some help understanding why this is not working.

 

Also if I wanted to highlight a value less than or equal to 3.50 (<=3.50) or greater than or equal to 4.50 (>=4.50) what would that look like? I tried the below measure and cannot get it to work either.

 

 
Highlight Average =
SWITCH(
    TRUE(),

    -- Condition 1
    SELECTEDVALUE('Voluntary 2s Removed'[Id]) = "1.1.2" &&
    SELECTEDVALUE('Voluntary 2s Removed'[Rate]) <= 3.50 || SELECTEDVALUE('Voluntary 2s Removed'[Rate]) >= 4.50,
    "Green",

    -- Default
    "White"
)
 
Any help is greatly appreciated! Thank you!
1 ACCEPTED SOLUTION
v-agajavelly
Community Support
Community Support

Hi @Easter-J 

Thanks for reaching out on the Microsoft Fabric Community Forum,

As @vicky_  suggested, try using the MAX function instead of SELECTEDVALUE. This approach is more stable, especially when your matrix is aggregating values.

Here’s a revised version of your measure using MAX, with a green highlight as you requested.

Highlight Color =

VAR _id = SELECTEDVALUE('Voluntary 2s Removed'[Id])

VAR _rate = MAX('Voluntary 2s Removed'[Rate]) -- You can also use AVERAGE or MIN depending on your needs

RETURN

SWITCH(TRUE(),
_id = "8.1.12" && _rate >= 2.90, "#A9DFBF",  -- Green

_id = "1.1.2" && (_rate <= 3.50 || _rate >= 4.50), "#F9E79F",  -- Yellow

"#FFFFFF"  -- Default white)

If your matrix is aggregating values, replacing SELECTEDVALUE(Rate) with an aggregation like MAX(Rate) or AVERAGE(Rate) ensures more consistent and reliable conditional formatting.

If this solution works for you, please consider marking it as accepted so others facing a similar issue can benefit too!

Let me know if you need help customizing the colors or logic further

Regards,
Akhil.

View solution in original post

6 REPLIES 6
v-agajavelly
Community Support
Community Support

Hi @Easter-J 

Just checking in one last time. Were you able to try out any of the suggestions shared earlier? If your issue is resolved, marking the accepted solution would be a big help to others who might be facing the same scenario.

If you went in a different direction or still need support, feel free to drop a quick update, we’re happy to keep helping.

Regards,
Akhil.

v-agajavelly
Community Support
Community Support

Hi  @Easter-J 

Just wanted to check in, do you still need a hand with this? Sometimes these things take a few tries to get right, so if you're seeing anything new or different, feel free to share and I’ll gladly take another look. And if one of the replies helped solve it, feel free to mark it as a solution so others can find it too. A quick “Kudos” is always appreciated as well.

Thanks,
Akhil.

Thank you for checking back in! I was able to figure it out with a combination of both your suggestion and @vicky_ feedback.

Hi @Easter-J 

That's awesome to hear glad you got it working. Sounds like a great collaboration between our suggestions and @vicky_  input. If you run into any issues in the future, feel free to reach out on the Microsoft Fabric Community forum, we're always happy to help.
And if a particular solution worked for you, don’t forget to mark it as accepted. It really helps others in the community too.

Regards,
Akhil.

v-agajavelly
Community Support
Community Support

Hi @Easter-J 

Thanks for reaching out on the Microsoft Fabric Community Forum,

As @vicky_  suggested, try using the MAX function instead of SELECTEDVALUE. This approach is more stable, especially when your matrix is aggregating values.

Here’s a revised version of your measure using MAX, with a green highlight as you requested.

Highlight Color =

VAR _id = SELECTEDVALUE('Voluntary 2s Removed'[Id])

VAR _rate = MAX('Voluntary 2s Removed'[Rate]) -- You can also use AVERAGE or MIN depending on your needs

RETURN

SWITCH(TRUE(),
_id = "8.1.12" && _rate >= 2.90, "#A9DFBF",  -- Green

_id = "1.1.2" && (_rate <= 3.50 || _rate >= 4.50), "#F9E79F",  -- Yellow

"#FFFFFF"  -- Default white)

If your matrix is aggregating values, replacing SELECTEDVALUE(Rate) with an aggregation like MAX(Rate) or AVERAGE(Rate) ensures more consistent and reliable conditional formatting.

If this solution works for you, please consider marking it as accepted so others facing a similar issue can benefit too!

Let me know if you need help customizing the colors or logic further

Regards,
Akhil.

vicky_
Super User
Super User

I believe the issue might come from the condition:

SELECTEDVALUE('Voluntary 2s Removed'[Rate]) >= 2.90

Double-check your summarisation of the rate column. If there's more than 1 "rate" value, then SELECTEDVALUE would actually be returning blank. The solution is to change "SELECTEDVALUE('Voluntary 2s Removed'[Rate]) >= 2.90" to MAX or SUM (depending on what you use in your table)

If you make the same change to the Highlight Average measure it should work the same.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.