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
BEcomeProPBI
New Member

SUM by Product and Date

Hi I have a table with 3 columns
1. Client number

2. Sales

3. Date

 

The sales are monthly so client number repeats for each date. I need to sum the first sale from each client number, there are two problems, one each client number has a different first month and first year, and since the client number keep repeating, it is hard to filter by date only. The number of rows are very high.

 

Can you help me?

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @BEcomeProPBI ,

 

Based on your description, what you want to calculate is a summary of the first sales of each client number.

You could try the DAX like below:

Measure = 
var min_date = CALCULATE(MIN(Sheet4[Date]),ALLEXCEPT(Sheet4,Sheet4[Client number]))
return CALCULATE(SUM(Sheet4[Sales]),FILTER(Sheet4,Sheet4[Date]=min_date))

Sample .pbix 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Hi @BEcomeProPBI ,

 

Based on your description, what you want to calculate is a summary of the first sales of each client number.

You could try the DAX like below:

Measure = 
var min_date = CALCULATE(MIN(Sheet4[Date]),ALLEXCEPT(Sheet4,Sheet4[Client number]))
return CALCULATE(SUM(Sheet4[Sales]),FILTER(Sheet4,Sheet4[Date]=min_date))

Sample .pbix 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@BEcomeProPBI ,

Try a new measure like

Measure =
VAR __id = MIN ( 'Table'[Client number] )
VAR __date = CALCULATE ( MIN( 'Table'[Date] ), ALLSELECTED ( 'Table' ), 'Table'[Client number] = __id )
RETURN CALCULATE ( sum ( 'Table'[Sales] ), VALUES ( 'Table'[Client number] ), 'Table'[Client number] = __id, 'Table'[date] = __date )

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.