cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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




Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

www.perytus.com
(MVP Data Platform)


2 ACCEPTED SOLUTIONS

Accepted Solutions
v-huizhn-msft Super Contributor
Super Contributor

Re: Top N Each Customer and Sales Amount

Hi @parry2k,

I create the following sample table.

1.PNGSample 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

Super User
Super User

Re: Top N Each Customer and Sales Amount

Hi @parry2k,

 

You may refer to my solution here.

 

Hope this helps.

4 REPLIES 4
Super User
Super User

Re: Top N Each Customer and Sales Amount

Hi,

 

Is this the result you are expecting?

 

Untitled.png

Super User
Super User

Re: Top N Each Customer and Sales Amount

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




Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

www.perytus.com
(MVP Data Platform)


v-huizhn-msft Super Contributor
Super Contributor

Re: Top N Each Customer and Sales Amount

Hi @parry2k,

I create the following sample table.

1.PNGSample 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

Super User
Super User

Re: Top N Each Customer and Sales Amount

Hi @parry2k,

 

You may refer to my solution here.

 

Hope this helps.