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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
yellow43
Helper I
Helper I

Calculate Cumulative Average Overtime

Hi Community, 

 

Need help to calculate cumulative average price per product overtime (since product started to be sold. I can have different dates for different products).

 

 Fact Table

ProductDate[Total Sales] [Quantity]
A31/1/20221503
A5/5/20221004
A6/5/2022101
B30/1/20241506
B2/2/20241003
C30/5/20231002
C5/7/20231502
D6/6/20223002

 

I would like to have a measure to be applied in a matrix visual that has a page Date Slicer.

Despite date applied in the slicer, it should show always the Cumulative Average Overtime Measure as follows: 

 

Output for measure:  

A - 32.50

B - 27.78

C - 62.50

D - 150

 

Thanks in advance. 

1 ACCEPTED SOLUTION
v-jiewu-msft
Community Support
Community Support

Hi @yellow43 ,

Based on my testing, please try the following methods:

1.Create the simple table.

vjiewumsft_0-1712886008877.png

2.Create the new measure to calculate cumulative average.

 

average_over = 
VAR product_sales = CALCULATE(SUM('Fact Table'[Total sales]), ALLEXCEPT('Fact Table', 'Fact Table'[Product]))
VAR product_quantity = CALCULATE(SUM('Fact Table'[Quantity]), ALLEXCEPT('Fact Table', 'Fact Table'[Product]))
RETURN
DIVIDE(product_sales, product_quantity)

 

3.Drag the measure into the matrix visual. The result is shown below.

vjiewumsft_1-1712886049194.png

vjiewumsft_2-1712886059842.png

 

Best Regards,

Wisdom Wu

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
yellow43
Helper I
Helper I

Thank you @v-jiewu-msft 

v-jiewu-msft
Community Support
Community Support

Hi @yellow43 ,

Based on my testing, please try the following methods:

1.Create the simple table.

vjiewumsft_0-1712886008877.png

2.Create the new measure to calculate cumulative average.

 

average_over = 
VAR product_sales = CALCULATE(SUM('Fact Table'[Total sales]), ALLEXCEPT('Fact Table', 'Fact Table'[Product]))
VAR product_quantity = CALCULATE(SUM('Fact Table'[Quantity]), ALLEXCEPT('Fact Table', 'Fact Table'[Product]))
RETURN
DIVIDE(product_sales, product_quantity)

 

3.Drag the measure into the matrix visual. The result is shown below.

vjiewumsft_1-1712886049194.png

vjiewumsft_2-1712886059842.png

 

Best Regards,

Wisdom Wu

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

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors