Forum Discussion

jts_'s avatar
jts_
Icon for Helper I rankHelper I
4 years ago
Solved

HELP! Calculate occurrence dynamically based on date slicer

Hi,   I am looking for a solution to calculate occurrence dynamically for the past 60 days of the maximum date on the slicer. The sample dataset is as below: Customer ID Visit Date A ...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi jts_ ,

     

    Here's my solution.

    1.Create a calendar table.

    Calendar = CALENDAR(DATE(2022,1,1),DATE(2022,12,31))

     

    2.Create a slicer for the max date.

     

    3.Create another measure for counting the visits.

    Visit Counts =
    CALCULATE (
        COUNT ( 'Table'[Customer ID] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            [Customer ID] = MAX ( 'Table'[Customer ID] )
                && [Visit Date]
                    >= SELECTEDVALUE ( 'Calendar'[MaxDate] ) - 60
                && [Visit Date] <= SELECTEDVALUE ( 'Calendar'[MaxDate] )
        )
    )
    

     

    4.Create a table visual.

    When the max date is  6/30/2022,

    When the max date is  5/31/2022,

     

     

    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.