Forum Discussion

yellow43's avatar
yellow43
Icon for Helper I rankHelper I
2 years ago
Solved

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. 

  • Anonymous's avatar
    Anonymous
    2 years ago

    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.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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.