Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
VuongLM93
Helper III
Helper III

Sum sales by customers with individual Start - End Date

I have a few tables:

1.  Dim - Customers  ( with start - end date) 

CustomerCodeCustomerNameStart DateEnd Date
C001A1-1-202130-1-2022
C002B1-10-202031-10-2022
C003C1-10-202031-10-2022
C00N

D

31-10-2022

31-10-2022

2.  Fact - Volume  quantity

 

CustomerCodeSKUVolume quantityDate invoice  
C001SKU 1101-1-2021  
C001SKU 2201-1-2021  
.......30   
C00N

SKU 2

40

 

 

 

 

How to sum the volume for each Customer Code within their respective Start -End date? 

 

CustomerCodeCustomerNameStart DateEnd DateTotal volume within period
C001A1-1-202130-1-2022?
C002B1-10-202031-10-2022 
C003C1-10-202031-10-2022 
C00N

D

31-10-2022

31-10-2022

 

]

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @VuongLM93 

I created a measure that may meet your needs .

Total volume within period

= CALCULATE(SUM('Fact - Volume  quantity'[Volume quantity]),

FILTER('Fact - Volume  quantity','Fact - Volume  quantity'[CustomerCode]=MAX('Dim - Customers'[CustomerCode])

                                                    && 'Fact - Volume  quantity'[Date invoice]>=MAX('Dim - Customers'[Start Date])

                                                     && 'Fact - Volume  quantity'[Date invoice]<=MAX('Dim - Customers'[End Date])))

 

The quantity within the period will be summed.

The effect is as shown:

Ailsa-msft_0-1617257470800.png

Ailsa-msft_1-1617257470801.png

Ailsa-msft_2-1617257470803.png

Best Regards

Community Support Team _ Ailsa Tao

 

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

4 REPLIES 4
Anonymous
Not applicable

Hi @VuongLM93 

I created a measure that may meet your needs .

Total volume within period

= CALCULATE(SUM('Fact - Volume  quantity'[Volume quantity]),

FILTER('Fact - Volume  quantity','Fact - Volume  quantity'[CustomerCode]=MAX('Dim - Customers'[CustomerCode])

                                                    && 'Fact - Volume  quantity'[Date invoice]>=MAX('Dim - Customers'[Start Date])

                                                     && 'Fact - Volume  quantity'[Date invoice]<=MAX('Dim - Customers'[End Date])))

 

The quantity within the period will be summed.

The effect is as shown:

Ailsa-msft_0-1617257470800.png

Ailsa-msft_1-1617257470801.png

Ailsa-msft_2-1617257470803.png

Best Regards

Community Support Team _ Ailsa Tao

 

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

@VuongLM93 , A new column in the customer table


sumx(filter(Volume, Volume[Date invoice] >= Customers[Start Date] && Volume[Date invoice] <= Customers[End Date] && Volume[CustomerCode] = Customers[CustomerCode]),Volume[Volume])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak  ,

Unfortunately I cannot create Customer Column due to it being a live dataset,

IS there a way to create a Measure instead?

@VuongLM93 , Try a measure like

calculate(sumx(values(Volume[CustomerCode]),Volume[Volume]),filter(Volume, Volume[Date invoice] >= min(Customers[Start Date]) && Volume[Date invoice] <= max(Customers[End Date]) && Volume[CustomerCode] = max(Customers[CustomerCode])))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors