Forum Discussion

vijayvizzu's avatar
vijayvizzu
Helper III
6 years ago
Solved

Average Cumulative not working

Hi Folks, I have been trying to fix the error, unable to resolve it. I had created a measure "Avg USD" which normally calculate average values for each month. Its working good, and now i had creaetd another measure "Cummulative Avg" to create a cumulative of average measure, which doesn't work.
Hence to check the calculation, i had created a measure "Total USD" to calculate the sum of values of a column, in this measure i just replaced the AVERAGEX function with SUMX, its working good too. Then i had created a measure "Cummulative" to generate the cummulative of Sum. This is working fine too.
I was wondering, why the same structure behaves differently with SUMX and AVERAGEX.
Please see the snapshot i have attached.
Could you please help,where i am doing wrong. I recently started working on this Power BI.

 

Problem pic

  • Hi,

     

    Please try this measure:

    Cummulative Avg =
    SUMX (
        SUMMARIZE (
            FILTER (
                ALLSELECTED ( Calendar ),
                'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
            ),
            'Calendar'[MonthYr],
            "Avg", [Avg USD]
        ),
        [Avg]
    )

     

    Best Regards,

    Giotto

7 Replies

  • v-gizhi-msft's avatar
    v-gizhi-msft
    Community Support

    Hi,

     

    Please try this measure:

    Cummulative Avg =
    SUMX (
        SUMMARIZE (
            FILTER (
                ALLSELECTED ( Calendar ),
                'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
            ),
            'Calendar'[MonthYr],
            "Avg", [Avg USD]
        ),
        [Avg]
    )

     

    Best Regards,

    Giotto

    • vijayvizzu's avatar
      vijayvizzu
      Helper III

      amitchandak : Yes, i am using custom calender table. Please see the relational model for your reference.

       

      • amitchandak's avatar
        amitchandak
        Super User

        vijayvizzu 

        Try Avg USD like this

        AverageX(summarize(CALENDAR,CALENDAR[MonthYr],"_sum",[Total USD]),[_sum])

         

        Seem like row context issue