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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
MithSingh
Frequent Visitor

Calculate the number of distinct teams where the earliest date is greater than the latest date score

Hello,

 

I need to calculate the number of distinct teams where the earliest date is greater than the latest date score, and I want to apply date filtering using a slicer. please help me out.

MithSingh_0-1692340666762.png

 

Thanks

1 ACCEPTED SOLUTION

Hi @MithSingh ,

 

Thanks for explaining the issue again.

 

I tried the following measure. This should work.

 

Test = 

var min_date = MIN(Score[Date])

var max_date = MAX(Score[Date])

var table1 = SUMMARIZE(Score,Score[Team])

var table2 = ADDCOLUMNS(table1,"MinScore",CALCULATE(SUM(Score[Score]),Score[Date]=min_date),"MaxScore",CALCULATE(SUM(Score[Score]),Score[Date]=max_date))

var table3 = ADDCOLUMNS(table2,"Flag",IF([MinScore]>[MaxScore],1,0))

return

COUNTX(FILTER(table3,[Flag]=1),DISTINCTCOUNT([Team]))

 

If this works, please mark this reply as the solution.

 

Thank you!

View solution in original post

4 REPLIES 4
MithSingh
Frequent Visitor

so if we select dates through silicer from 1/1/2023 to 1/2/2023, then 

 

These Teams will meet the criteria:
Team B because it's earliest date has a score 5 and the latest date score has 2, so the earliest date is greater than the latest date score
Team D because it's earliest date has a score 6 and the latest date score has 2, so the earliest date is greater than the latest date score

 

so measure should return the result = 2, total unique team count

Hi @MithSingh ,

 

Thanks for explaining the issue again.

 

I tried the following measure. This should work.

 

Test = 

var min_date = MIN(Score[Date])

var max_date = MAX(Score[Date])

var table1 = SUMMARIZE(Score,Score[Team])

var table2 = ADDCOLUMNS(table1,"MinScore",CALCULATE(SUM(Score[Score]),Score[Date]=min_date),"MaxScore",CALCULATE(SUM(Score[Score]),Score[Date]=max_date))

var table3 = ADDCOLUMNS(table2,"Flag",IF([MinScore]>[MaxScore],1,0))

return

COUNTX(FILTER(table3,[Flag]=1),DISTINCTCOUNT([Team]))

 

If this works, please mark this reply as the solution.

 

Thank you!

Yes, It's working. Thank you Sir:) It's a great help.😊😊

Prateek97
Resolver III
Resolver III

Hi @MithSingh ,

 

Can you please explain in little detail. Out of the rows that you have shared which row will meet the criteria you have mentioned.

 

What I could understand is you want the Count of Teams where the Earliest date's score is greater than the Latest Date's score.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors