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
parry2k
Super User
Super User

Top N Each Customer and Sales Amount

Hi there,

 

I have following data:

 

Date, Customer Name and Sales Amount

 

I am looking for date on which the highest sales happend for each customer, highest sales means sum of sales for each date.

 

Customer   Highest Date for the Sale   Total Amount of sales on highest sales date

 

I hope it is pretty straight forward. Thanks in advance.

 

P



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

2 ACCEPTED SOLUTIONS

Hi @parry2k,

I create the following sample table.

Sample tableSample table
First, create two calculated column using the formulas.

Each customer'sales in each date = CALCULATE(SUM(Table4[Sales amount]),ALLEXCEPT(Table4,Table4[Customer Name],Table4[Date]))

MAx sales for each customer = CALCULATE(MAX(Table4[Each customer'sales in each date]),ALLEXCEPT(Table4,Table4[Customer Name]))

2.PNG

Second, create two measures using the formulas below.

Highest Date for the Sale = CALCULATE(FIRSTDATE(Table4[Date]),FILTER(Table4,Table4[Each customer'sales in each date]=Table4[MAx sales for each customer]))

Total Amount of sales on highest sales date = MAX(Table4[Each customer'sales in each date])


Finally, create a table visual, select the customer name and the two measures as values, you will get expected result.

5.PNG

Best Regards,
Angelia

View solution in original post

Hi @parry2k,

 

You may refer to my solution here.

 

Hope this helps.


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

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

 

Is this the result you are expecting?

 

Untitled.png


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

Yes @Ashish_Mathur. Will be helpful if you share the formulas. Thanks



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k,

 

You may refer to my solution here.

 

Hope this helps.


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

Hi @parry2k,

I create the following sample table.

Sample tableSample table
First, create two calculated column using the formulas.

Each customer'sales in each date = CALCULATE(SUM(Table4[Sales amount]),ALLEXCEPT(Table4,Table4[Customer Name],Table4[Date]))

MAx sales for each customer = CALCULATE(MAX(Table4[Each customer'sales in each date]),ALLEXCEPT(Table4,Table4[Customer Name]))

2.PNG

Second, create two measures using the formulas below.

Highest Date for the Sale = CALCULATE(FIRSTDATE(Table4[Date]),FILTER(Table4,Table4[Each customer'sales in each date]=Table4[MAx sales for each customer]))

Total Amount of sales on highest sales date = MAX(Table4[Each customer'sales in each date])


Finally, create a table visual, select the customer name and the two measures as values, you will get expected result.

5.PNG

Best Regards,
Angelia

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.