cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MakeItReal
Post Patron
Post Patron

Flag or highlight row across several columns in table based on value condition

Hello,

I have the following table and i want to flag or highlight the entire row if the number of Sold items are 90% or more of Stock items. I used a calculated column for the Difference column in a table visualization. Any help is much appreciated!

 

Week numberStockSoldDifference
11218932
221220012
314210537
48468451
555250052
623131200
751451463
8874551323
954884464
101525498
11516156360
126146140

 

1 ACCEPTED SOLUTION
PaulDBrown
Super User
Super User

Create a measure to use for the conditional formatting along the lines of:

flag = 

VAR _Threshold = DIVIDE(SUM(Table[Sold]), SUM(Table[Stock]))

RETURN

IF(_Threshold >= 0.9, "Red")

 

Select each field and add the conditional formatting using the option of "Field value" and selecting the [flag] measure

You will need to use the measure for the conditional formatting for each column and in the table visual 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

3 REPLIES 3
PaulDBrown
Super User
Super User

Create a measure to use for the conditional formatting along the lines of:

flag = 

VAR _Threshold = DIVIDE(SUM(Table[Sold]), SUM(Table[Stock]))

RETURN

IF(_Threshold >= 0.9, "Red")

 

Select each field and add the conditional formatting using the option of "Field value" and selecting the [flag] measure

You will need to use the measure for the conditional formatting for each column and in the table visual 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown Thanks for your reply! It works. But as an improvement, could you please advise how to make it work as follows for the "Difference" column, based on the following rules:

1. If the number of Sold items are less than 50% of Stock items, then green icon.

2. If the number of Sold items is at least 50% but less than 90% of Stock items, then yellow icon.

3. If the number of Sold items is 90% or greater than Stock items, then red icon.

 

MakeItReal_0-1659633337238.png

 

Use this measure with the conditional formatting for icons:

Icon flag =
VAR _Threshold =
    DIVIDE ( SUM ( 'Table'[Sold] ), SUM ( 'Table'[Stock] ) )
RETURN
    SWITCH ( TRUE (), 
_Threshold < 0.5, 1, 
_Threshold < 0.9, 2, 
3 )

Use it for the Difference field

icon flag.png

 

icons.png

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.