Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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
Product | Date | [Total Sales] | [Quantity] |
A | 31/1/2022 | 150 | 3 |
A | 5/5/2022 | 100 | 4 |
A | 6/5/2022 | 10 | 1 |
B | 30/1/2024 | 150 | 6 |
B | 2/2/2024 | 100 | 3 |
C | 30/5/2023 | 100 | 2 |
C | 5/7/2023 | 150 | 2 |
D | 6/6/2022 | 300 | 2 |
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.
Solved! Go to Solution.
Hi @yellow43 ,
Based on my testing, please try the following methods:
1.Create the simple table.
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.
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.
Hi @yellow43 ,
Based on my testing, please try the following methods:
1.Create the simple table.
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.
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.