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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
muhaiza
Frequent Visitor

Conditional Formatting based on specific value for each row

muhaiza_0-1645517790253.png

Hi i need help to make conditional formatting but each row depends on different value.
at 'On Hand qty', the background color depends on the 'Target quantity' such as:

on the fifth row, 'target quantity' is 3,
so if 'on hand qty' >= 3 is green, and 3 < is red

but,
on the seventh row, 'target quantity' is 13,
so if 'on hand qty' >= 13 is green, and 13 < is red
 

1 ACCEPTED SOLUTION

@muhaiza Please update your code as below:-

measure 3=
IF (
    SUM ( INF[On Hand Qty] ) >= INT ( MAX ( INF[Target Quantity] ) ),
    "Green",
    "Red"
)

Output:-

Samarth_18_0-1645692118283.png

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

10 REPLIES 10
Samarth_18
Community Champion
Community Champion

Hi @muhaiza ,

 

If on hand qty and target quantity are measure then try this:-

measure 3 = if( [OnHand Qunatity] >= [target quantity] , "Green","Red")

or if those are column then use below code:-

measure 3 = if( sum(table[OnHand Qunatity]) >= sum(table[target quantity]) , "Green","Red")

Now add this measure like below for conditional formatting:-

Samarth_18_0-1645685681508.png

Samarth_18_1-1645685703849.png

 

Thanks,

Samarth

 

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi @Samarth_18 ,

why it says the value cannot be determined? i'am very sure the spelling of my column is all true

muhaiza_0-1645687318046.png

 

Please try this:-

measure 3 = if( sum(table[OnHand Qunatity]) >= sum(table[target quantity]) , "Green","Red")

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

okay, now the coding seems working, but why i can't click on the measure 3?😢

muhaiza_0-1645688035501.pngmuhaiza_1-1645688092970.png

 

@muhaiza Is it possible for you to share your PBIX file after removing sensitive data?

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

@muhaiza Please update your code as below:-

measure 3=
IF (
    SUM ( INF[On Hand Qty] ) >= INT ( MAX ( INF[Target Quantity] ) ),
    "Green",
    "Red"
)

Output:-

Samarth_18_0-1645692118283.png

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

@Samarth_18 Thank youuu so much!!

amitchandak
Super User
Super User

@muhaiza , Create a new color measure

 

Switch( True() ,

[target quantity] = 3 && [OnHand Qunatity] >=3 , "Green",

[target quantity] = 3 && [OnHand Qunatity] < 3  , "Red",

[target quantity] = 13 && [OnHand Qunatity] >=13 , "Green",

[target quantity] = 13 && [OnHand Qunatity] <13 , "Red"

)

 

Change the value as per need.  Use in conditional formatting using field value option

How to do conditional formatting by measure and apply it on pie? : https://youtu.be/RqBb5eBf_I4

Hi @amitchandak , Thank you! 
Sorry, i'm still new to this but why it says 'cannot find name'?
do i need to declare something first?

muhaiza_0-1645679044256.png

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.