Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Count Distinct customer IDs repeating last rolling 90 days

I have a table with customer IDs, week-end dates, sales. I am able to create a table that shows by month ending date the distinct count of customer IDs in the last rolling 90 days. However unable t...
  • v-jingzhang's avatar
    v-jingzhang
    5 years ago

    Hi Anonymous 

    I am not sure what your data looks like so I use some simple data to realize this. Please download this PBIX file for details.

    I create a table to get the transaction count of each customer in a month and will use it in a measure.

    Monthly_Count = 
    SUMMARIZE (
        'Table',
        'Table'[Last WE of Month],
        'Table'[Customer ID],
        "Count In A Month", COUNT ( 'Table'[Customer ID] )
    )

    Then create a measure to get the number of customers buying more than one time in 90 days.

    Measure_2 = 
    VAR thisWeekEOM =
        MAX ( 'Table'[Last WE of Month] )
    VAR _table =
        FILTER (
            'Monthly_Count',
            'Monthly_Count'[Last WE of Month] <= thisWeekEOM
                && 'Monthly_Count'[Last WE of Month] > thisWeekEOM - 90
        )
    VAR _table2 =
        SUMMARIZE (
            _table,
            'Monthly_Count'[Customer ID],
            "Count in 90 Days", SUM ( 'Monthly_Count'[Count In A Month] )
        )
    VAR countValue =
        COUNTX (
            FILTER ( _table2, [Count in 90 Days] > 1 ),
            'Monthly_Count'[Customer ID]
        ) + 0
    RETURN
        countValue

    Kindly let me know if this helps.
    Community Support Team _ Jing Zhang
    If this post helps, please consider Accept it as the solution to help other members find it.