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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Top N of sum of column per name per date

Let's say I have three columns:

 

NAME: Name of personel

SALES: Amount to be summed

DATE: date

 

I can not manage to make a top 10 of NAMEs that have the highest SALES per DATE

 

For example if this is data:

 

NameDateSales
A160
A1150
B3225
C2

150

D5

125

A2

100

 

A top 3 should look like this:

 

NameDateSales
B3225
A1210
C2150

 

I can make a table sorted by Sales of above three columns showing all data with correct sum of sales per date per name, however once I filter that visual by Name -> Top N - > top 10 by Sales, I get complete gibberish. How do I go about this?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try a new measure like this and filter for <=3 

rankx(allselected(Table[name], table[date]), calculate(sum(table[sales])))

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
ttps://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

OK so this is weird. Your solution DOES work, but not yet in the way I want it to. 

 

The top 10 is made from data from table A.

Table A contains a date column, which contains weirdly formatted dates that I don''t use anywhere in the report.

Table A is linked to column B through a Transaction ID (each transaction ID = one row that also contains name and sales amount). Column B has the correct date format for each transaction ID. The date format in column B is linked to a Date Table (dates, weeks, months, years) that I use throughout the report and seems to work correctly when summarizing data from Table A.

 

However... when I use the date column from the Date Table in my Top N table, I get gibberish values. If I use the date column from Table A, I get a correct top 10 table. Even though the date translation (date, weeks, months, etc.) seems to work correctly for all other visualizations that use data from Table A?

 

How do I make the table with the correct dates from the Date Table?

 

EDIT: I'll mark this as solved as a solution was given for the original question. I'll post the new question in a new topic.

 

amitchandak
Super User
Super User

@Anonymous , Can you share a bigger sample. I tried the measure I shared above and got the results

 

amitchandak_0-1607995188524.png

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
amitchandak
Super User
Super User

@Anonymous , Try a new measure like this and filter for <=3 

rankx(allselected(Table[name], table[date]), calculate(sum(table[sales])))

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
ttps://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you for the quick reply. I've seen this posted and tried it, but this doesn't give the desired result.

 

If I just make the table (no top N, no fancy filtering), the top 10 of sales per date per employee (in a very very large table) show the correct numbers. There are no duplicates of values in the top 10 of that very large table. However once I try your solution to make a actual top 10 list, the highest value is not on top anymore. There is a whole bunch of values that have ranking "1", i.e. I end up with a much larger list than a Top 10, even though there are no duplicate values in the actual top 10 ?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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