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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ksfx77
Helper I
Helper I

Help with showing user retention

Hi Guys - I hope you are all well !

 

I have a conundrum, and would appreciate your guidance 🙂

 

I have an events table, as per the following example.

 

DateUserGuidAction
1/26/2021<unique guid>REGISTER
1/26/2021<unique guid>LOGIN
1/26/2021<unique guid>LOGIN
1/26/2021<unique guid>REGISTER


I need to generate a user retention graph showing those who continue to login after 1 day, 7 days, and 20 days (and potentially other days).

 

  • The REGISTER event will happen once per user, and shows when they first signed up.
  • The LOGIN event occurs every time a user logs in to the platform.

 

So I need to work out for each user;

  • Their register date
  • If they logged in after registering (Day 1) - same day or >
  • If they logged in >= 7 days (from their register date)
  • If they logged in >= 30 days (from their register date)

 

This would then be shown in an aggregated manner, so what % of all users log in after 1 day, 7 days and so on.

 

I would very much appreciate any guidance!

 

Thanks all

Kevin

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @ksfx77 ,

 

According to my understanding, you want to set a flag for each User based on the date diff between the first register date and the first login date, and then calculate the percentage of all records, right?

You could use the following formula to create a calculated table :

Table 2 =
ADDCOLUMNS (
    DISTINCT ( 'Table'[UserGuid] ),
    "Flag",
        VAR _regiDate =
            CALCULATE (
                MAX ( 'Table'[Date] ),
                FILTER (
                    ALLEXCEPT ( 'Table', 'Table'[UserGuid] ),
                    'Table'[Action] = "REGISTER"
                )
            )
        VAR _firstLogin =
            CALCULATE (
                MIN ( 'Table'[Date] ),
                FILTER ( ALLEXCEPT ( 'Table', 'Table'[UserGuid] ), 'Table'[Action] = "Login" )
            )
        VAR _datediff =
            DATEDIFF ( _regiDate, _firstLogin, DAY )
        RETURN
            IF (
                _datediff >= 30,
                "30 Days",
                IF ( _datediff >= 7, "7 Days", IF ( _datediff >= 0, "1 Days" ) )
            )
)

Then directly create a line visual with Flag column like this:

1.28.2.1.jpg

Or create a Percentage column for table visual:

Percentage =
CALCULATE (
    COUNT ( 'Table 2'[Flag] ),
    ALLEXCEPT ( 'Table 2', 'Table 2'[Flag] )
)
    / COUNTROWS ( 'Table 2' )

 1.28.2.2.PNG

Please take a look at the pbi file here.

 

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

View solution in original post

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi @ksfx77 ,

 

According to my understanding, you want to set a flag for each User based on the date diff between the first register date and the first login date, and then calculate the percentage of all records, right?

You could use the following formula to create a calculated table :

Table 2 =
ADDCOLUMNS (
    DISTINCT ( 'Table'[UserGuid] ),
    "Flag",
        VAR _regiDate =
            CALCULATE (
                MAX ( 'Table'[Date] ),
                FILTER (
                    ALLEXCEPT ( 'Table', 'Table'[UserGuid] ),
                    'Table'[Action] = "REGISTER"
                )
            )
        VAR _firstLogin =
            CALCULATE (
                MIN ( 'Table'[Date] ),
                FILTER ( ALLEXCEPT ( 'Table', 'Table'[UserGuid] ), 'Table'[Action] = "Login" )
            )
        VAR _datediff =
            DATEDIFF ( _regiDate, _firstLogin, DAY )
        RETURN
            IF (
                _datediff >= 30,
                "30 Days",
                IF ( _datediff >= 7, "7 Days", IF ( _datediff >= 0, "1 Days" ) )
            )
)

Then directly create a line visual with Flag column like this:

1.28.2.1.jpg

Or create a Percentage column for table visual:

Percentage =
CALCULATE (
    COUNT ( 'Table 2'[Flag] ),
    ALLEXCEPT ( 'Table 2', 'Table 2'[Flag] )
)
    / COUNTROWS ( 'Table 2' )

 1.28.2.2.PNG

Please take a look at the pbi file here.

 

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

lbendlin
Super User
Super User

please provide more representative sample data, with real fake user ids, and sufficient time range.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.