Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
viggo71
Frequent Visitor

DAX Formula for repeat rate

Hello,

 

i want to find a user repeat rate on a specific period.

 

Basic data :

date User ID
15/06/2021A
15/06/2021A
15/06/2021B
16/06/2021C
16/06/2021D
18/06/2021E

 

And i want to have :

date Users reiterating users reiterating rate 2 days reiterating rate
15/06/20213133%33%
16/06/2021200%20%
18/06/2021100%0%

 

What's the DAX formula for "2 days reitarting rate", please ?

Thanks

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @viggo71 

 

First add an Index column to the table to rank the dates.

Index = RANKX('Table','Table'[date],,ASC,Dense)

062304.jpg

Then create the following measure.

Measure 2 = 
VAR _currentDateIndex = MAX('Table'[Index])
VAR _startDateIndex = _currentDateIndex - 1
VAR _table = FILTER(ALL('Table'),'Table'[Index]>=_startDateIndex && 'Table'[Index]<=_currentDateIndex)
VAR _table2 = SUMMARIZE(_table,'Table'[User ID],"Occurrences",COUNT('Table'[User ID]))
VAR _allrecords = COUNTROWS(_table)
VAR _repeatedUsers = COUNTROWS(FILTER(_table2,[Occurrences]>1))
RETURN
DIVIDE(_repeatedUsers,_allrecords)+0

062303.jpg

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @viggo71 

 

First add an Index column to the table to rank the dates.

Index = RANKX('Table','Table'[date],,ASC,Dense)

062304.jpg

Then create the following measure.

Measure 2 = 
VAR _currentDateIndex = MAX('Table'[Index])
VAR _startDateIndex = _currentDateIndex - 1
VAR _table = FILTER(ALL('Table'),'Table'[Index]>=_startDateIndex && 'Table'[Index]<=_currentDateIndex)
VAR _table2 = SUMMARIZE(_table,'Table'[User ID],"Occurrences",COUNT('Table'[User ID]))
VAR _allrecords = COUNTROWS(_table)
VAR _repeatedUsers = COUNTROWS(FILTER(_table2,[Occurrences]>1))
RETURN
DIVIDE(_repeatedUsers,_allrecords)+0

062303.jpg

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

viggo71
Frequent Visitor

Hi, thanks Pat but it doesn't work. I need a distinct count of duplicate ID on X rolling days.

Thanks

mahoneypat
Microsoft Employee
Microsoft Employee

Here's a measure that shows one way to do it.  Replace "Reiterate" with your actual table name.

 

Two Day Rate =
VAR thisdate =
    MAX ( Reiterate[date] )
VAR prevdate =
    CALCULATE ( MAX ( Reiterate[date] ), Reiterate[date] < thisdate )
VAR result =
    CALCULATE (
        DIVIDE (
            COUNT ( Reiterate[ User ID] ) - DISTINCTCOUNT ( Reiterate[ User ID] ),
            COUNT ( Reiterate[ User ID] )
        ),
        FILTER (
            ALL ( Reiterate[date] ),
            Reiterate[date] <= thisdate
                && Reiterate[date] >= prevdate
        )
    )
RETURN
    result

 

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.