Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Calculating cumulative - smooth average

I have a data set of different categories (Unique Well ID) with monthly oil production. The average plot doesn't look smooth, since oil production stops earlier. 

 

I created a measure

Cumulative oil =

CALCULATE(

     SUM(prod_injection[PRD Moving Avg OIL m3]),

     FILTER(

         ALL(prod_injection),

         prod_injection[Date] <= MAX(prod_injection[Date])

     )

)

 The screenshot is attached. To make the smooth average, I think I need to keep calculating Cumulative oil beyond the end of "prod_injection[PRD Moving Avg OIL m3]" for an individual "Unique Well ID", as a constant (flat line), until the longest (maximum) "Cumulative Months" 

 

Thank you for your help

 

 

 

2 Replies

  • Anonymous , You should always use a date table in such case.

     

    Sum Measure

     

    Cumulative oil =

    CALCULATE(

    SUM(prod_injection[PRD Moving Avg OIL m3]),

    FILTER(

    ALL(Date),

    Date[Date] <= MAX(Date[Date])

    )

    )

     

    Avg Measure

     

    Cumulative oil =

    CALCULATE(

    Average(prod_injection[PRD Moving Avg OIL m3]),

    FILTER(

    ALL(Date),

    Date[Date] <= MAX(Date[Date])

    )

    )

     

    Avg of Sum Measure

     

    Cumulative oil =

    CALCULATE(

    AverageX(Values(Date[Date]), calculate(Sum(prod_injection[PRD Moving Avg OIL m3]))),

    FILTER(

    ALL(Date),

    Date[Date] <= MAX(Date[Date])

    )

    )

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Try using the smooth line provided by sparkline visual to see if it helps you.


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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