Forum Discussion

etane's avatar
etane
Icon for Helper V rankHelper V
2 years ago
Solved

Running Average per Month with Month Filter

Hello.

 

I need a DAX for the requirement below:

 

I am trying to add a card to report.  This card should calculate the running average of store openings per month.  And, it should be filterable by the calendar.  For example, without any filtering, I should see 20 store openings divided by 6 months to yield 3.33:

And, if I filter for March thru May, average should yield 2.33:

Here's a link to a simple data model:
Link

Thanks.

  • Hi etane 
    You can use dax:

    Average opend =
     var max_month = month(max('Stores'[Opened Date]))
     Var min_month = month(min('Stores'[Opened Date]))
     var months = max_month-min_month+1
     RETURN
    divide (DISTINCTCOUNT(Stores[Stores]),months)
    Result:

     

    the updated pbix is attached

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

2 Replies

  • Hi etane 
    You can use dax:

    Average opend =
     var max_month = month(max('Stores'[Opened Date]))
     Var min_month = month(min('Stores'[Opened Date]))
     var months = max_month-min_month+1
     RETURN
    divide (DISTINCTCOUNT(Stores[Stores]),months)
    Result:

     

    the updated pbix is attached

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

  • Thanks Ritaf1983

    Your logic is sound.  My actual model has activity across multiple years, products and status.  With you help, I was able to come up with a dax that suits my model.... something like this: