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

Proud to be a Datanaut!

www.perytus.com
(MVP Data Platform)

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super Contributor

## Re: Top N Each Customer and Sales Amount

Hi @parry2k,

I create the following sample table.

Sample 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]))

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.

Best Regards,
Angelia

Highlighted
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

## Re: Top N Each Customer and Sales Amount

Hi,

Is this the result you are expecting?

Super User

## Re: Top N Each Customer and Sales Amount

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

Proud to be a Datanaut!

www.perytus.com
(MVP Data Platform)

Super Contributor

## Re: Top N Each Customer and Sales Amount

Hi @parry2k,

I create the following sample table.

Sample 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]))

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.

Best Regards,
Angelia

Highlighted
Super User

## Re: Top N Each Customer and Sales Amount

Hi @parry2k,

You may refer to my solution here.

Hope this helps.