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
mdrammeh
Helper III
Helper III

How to Show Top 4 Highest Payment In Large Dataset

I am using PowerQuery to perform the following tasks and need some guidance on how to perform this task. I would also like to understand how I can use a similar criteria in Power BI deskstop.

 

The Problem:

I have a large dataset with a list of customer accounts showing 12 consecutive payments by each customer. For each customer, I only want to capture the top  4 highest payments received over the last 12 months. This could either be a calculated column or summary. 

 

What would be the best approach to tackle this problem?

 

Thank you in advance. 

 

Picture-Problem.PNG

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @mdrammeh,

 

Instead of doing it in M, why not just use DAX. You can  create a  measure using RANKX or TOPN. The measure would look something like this (I don't have PBI right now, so I'm only imagininig this, hopefully this wont return an error).

 

RANK BY MONTH =
//calculate rank by month based on payment amount
VAR RANK_ =
    RANKX ( ALL ( 'Table'[Month Column] ), SUM ( 'Table'[Payment Amount] ) ) 
//returns top 4 months only RETURN CALCULATE ( SUM ( 'Table'[Payment Amount] ), FILTER ( 'Table', RANK_ <= 4 ) )

Then you can place this measure inside a table or matrix together with the customer account number and the month. All non-top4 months should now show on the table.

 

 





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.

View solution in original post

1 REPLY 1
danextian
Super User
Super User

Hi @mdrammeh,

 

Instead of doing it in M, why not just use DAX. You can  create a  measure using RANKX or TOPN. The measure would look something like this (I don't have PBI right now, so I'm only imagininig this, hopefully this wont return an error).

 

RANK BY MONTH =
//calculate rank by month based on payment amount
VAR RANK_ =
    RANKX ( ALL ( 'Table'[Month Column] ), SUM ( 'Table'[Payment Amount] ) ) 
//returns top 4 months only RETURN CALCULATE ( SUM ( 'Table'[Payment Amount] ), FILTER ( 'Table', RANK_ <= 4 ) )

Then you can place this measure inside a table or matrix together with the customer account number and the month. All non-top4 months should now show on the table.

 

 





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.

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.