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! Appreciate your Kudos
Feel free to email me with any of your BI needs.

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

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! Appreciate your Kudos
Feel free to email me with any of your BI needs.

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

Super User

## Re: Top N Each Customer and Sales Amount

Hi @parry2k,

You may refer to my solution here.

Hope this helps.

Announcements

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

#### Power Platform Summit North America

Register by September 5 to save \$200

#### Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 292 members 2,741 guests
Recent signins: