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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Kalaivani
Helper III
Helper III

Get the Rank for the qualifying conditions

Hi All,

I have a requirement where I need to give color coding for measures in a table like

 

When Target

>=90% then green,

<90% for the first time, then yellow

<90% after first time, then red

 

I created a measure to find the missed targets as below. 

 

MissedTarget =
CALCULATE(COUNTROWS(FILTER(SUMMARIZE('Template Expectations','Template Expectations'[PostPeriod],"TemplateExpValue"[TemplateExpectations]),[TemplateExpectations] <0.9)))

 

But actually I want this to be like 1, 2, 3 based on the order of postperiod. So that I can color code yellow for Missed Target = 1 and red for MissedTarget >1

So the expected output has to be 1, 2, 3 for ID 66159 where MissedTarget is 1 and 1, 2 for ID 154179 where MissedTarget is 1

Kalaivani_0-1735730687681.png


Thanks so much for your help!!!!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Kalaivani ,

 

Use the following formula as the basis for setting the background color:

NewRule = IF(COUNTROWS(FILTER(ALL('Table'),'Table'[ID]=MAX('Table'[ID])&&[Measure]=BLANK()))>0,0.1,IF([Count_Less_Than_90]=1,SUMX(FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[Month]<=MAX('Table'[Month])),[Count_Less_Than_90])))

vlinhuizhmsft_0-1735871568807.png

Result:

vlinhuizhmsft_1-1735871636736.png

Best Regards,
Zhu

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

View solution in original post

13 REPLIES 13
Anonymous
Not applicable

Thanks for the replies from danextian, powerbiexpert22 and Ashish_Mathur.

 

Hi @Kalaivani ,

 

If you also need to show the exact number of times less than 90% occurs, you can create the following measure:

Count_Less_Than_90 = CALCULATE(COUNTROWS('Table'),FILTER('Table',[Measure]<0.9))
Count_Less_Than_90_Cumulative = IF([Count_Less_Than_90]=1,SUMX(FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[Month]<=MAX('Table'[Month])),[Count_Less_Than_90]))

 

Set background color rules:

vlinhuizhmsft_0-1735789309876.png

Result:

vlinhuizhmsft_1-1735789380333.png

Best Regards,
Zhu

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

Hi @Anonymous 

 

This is cool!!!!!!! Thanks so much. It's working.I have one more condition where when the values are blank for any month, it should show as white. How to achieve that? Thanks again!

Anonymous
Not applicable

Hi @Kalaivani ,

 

Use the following formula as the basis for setting the background color:

NewRule = IF(COUNTROWS(FILTER(ALL('Table'),'Table'[ID]=MAX('Table'[ID])&&[Measure]=BLANK()))>0,0.1,IF([Count_Less_Than_90]=1,SUMX(FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[Month]<=MAX('Table'[Month])),[Count_Less_Than_90])))

vlinhuizhmsft_0-1735871568807.png

Result:

vlinhuizhmsft_1-1735871636736.png

Best Regards,
Zhu

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

Hi @Anonymous Thanks so much for the answer

powerbiexpert22
Impactful Individual
Impactful Individual

Hi @powerbiexpert22 I have a case where the second month Aug 2024 value is less than 90% and for July 2024 the value is greater than 90%. In that case, my rank is showing as 2 for the first case where value is <90%
The underlined blue row for Aug 2024 for the ID 180440 has to be 1. Thanks again for your help!!

Kalaivani_0-1735873202955.png

 

Hi @powerbiexpert22 Thanks so so much for your help! It's working. 

danextian
Super User
Super User

Hi @Kalaivani 

 

Can you pleast post a workable sample data (not an image), your expected result from that and the reasoning behind?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian I am not able to attach files in here. Could you please help me with calculating rank for the measure MissedTarget. I think that will solve the solution

It is hard to provide a solution when there is no sample data to work on. You may post a url of the sanitized copy of the pbix saved in the cloud.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian i uploaded the power bi file with sample data in the drive. could you please access it and send me request access so that i can provide access to you to download the file. I am not able to upload to the cloud.

 

Thanks so much for your help!!

 

https://drive.google.com/drive/homehttps://drive.google.com/file/d/1fj6fStKlJRWC6acJH3BwXY68flJaIkr0...

danextian_0-1735798067443.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi,

Access Denied message.  Check the link again.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.