Forum Discussion

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

Dynamic average

Hi,   MEET_DATE        MONTH+1            MONTH+2      MONTH+3     MONTH+4   MONTH+5 ( in september) 2024-01-01    10 12 14 15   Here is my dataset actually. I want to calcul...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi psorel ,

     

    For calculating a dynamic average, you can do the following. Hope it helps.

    My sample data is as follows. Date is "MM/DD/YYY" format.

    Create a calculated table to generates month numbers for adding.

     

    Create a measure to calculate the dynamic average.

    Average = 
    var _sel=SELECTEDVALUE('Table 2'[Value])
    var _start=MIN('Table'[Date])
    var _end=EOMONTH(_start,_sel)
    return 
    DIVIDE(CALCULATE(SUM('Table'[Value]),FILTER('Table',[Date]>=_start&&[Date]<=_end)),_sel+1)

    Here's the result. When I selected 2 in the slicer, the average is (1+2+3)/3=2 .

    Best Regards,

    Stephen Tao

     

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