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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Get top 2 values across selected period

Hi, hopefully someone can help me with this.

I recently raised a ticket regarding how to get the top 1 value from a selected period (see below) however I am struggling to get the top 2.

https://community.powerbi.com/t5/Desktop/Measure-to-get-Value-with-the-highest-SUM/m-p/1395638#M5929...

My issue is I have a table that looks like the below

DateDescriptionCalls
01/01/2020Legal2362
01/01/2020ID345
01/01/2020Helpline723
02/01/2020Legal1023

 

Now if I am only looking at one day, the below dax works fine - however if I move my slider to look across multiple days, "Legal" would appear twice as the Description with the most Calls - this is because it had the most on both 01/01/2020 and 02/01/2020. Based on the above table, I would want my first measure  (MostCommon) to show "Legal" as it would have a combined Call count of 3385. The second measure (SecondMostCommon) would be Helpline with a Call Count of 723.

This is the query I use for the Most Common measure however I can't seem to get it to work for the second most common in the period?

CALCULATE (
VALUES ( 'ReportTable'[Description] ),
FILTER ( ALL ('ReportTable'[Calls] ), 'ReportTable'[Calls] = MAX ( 'ReportTable'[Calls] ) )

5 REPLIES 5
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

Not clear for your expected output, What is your expected based on this sample data?

Please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
vanessafvg
Super User
Super User

can you provide some sample data?




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

Hi hopefully this is useful?

DateDescriptionCalls
01/01/2020Legal2354
01/01/2020IT273
01/01/2020Helpline27
02/01/2020Legal1389
02/01/2020IT334
02/01/2020Helpline23
03/01/2020Legal1400
03/01/2020IT321
03/01/2020Helpline46

there are many ways to do it, and this probably isn't the most elegant solution but effectively you need to rank your values and use that ranking to drive the results you want.  see attached.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

Hi thank you for this it was a great help in getting me to understand ranking!

All I need now is a measure that just shows me the [Description] where the Rank is 1 and another where the rank is 2.

 

I have tried the below but it isn't giving me the correct answer

Any ideas on how to get this working?

 

CALCULATE(FIRSTNONBLANK(ReportTable[Description],1),FILTER(ReportTable, [rank] = 1))

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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