Forum Discussion

galgadot10's avatar
galgadot10
Regular Visitor
2 years ago
Solved

Calculate active users within a timeframe

Hello all! I've been stuck on this one for a while and could use some help please! As a gym owner, I have a table of gym sessions per member: Member Dates visited Anna 19/03/2023 Anna 28...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi galgadot10 ,

     

    I suggest you to create a calendar table to help your calculation.

    Calendar = ADDCOLUMNS(CALENDARAUTO(),"Year",YEAR([Date]),"Month",FORMAT([Date],"MMMM"),"MonthSort",MONTH([Date]))

    Data model:

    Measure:

    Count =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Member] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Dates visited] <= MAX ( 'Calendar'[Date] )
                && EOMONTH ( 'Table'[Dates visited], 3 ) >= MAX ( 'Calendar'[Date] )
        )
    )

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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