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
Anonymous
Not applicable

Formula for retained customers in terms of logins

Hello, 

 

I have a dataset that looks like this:

User IDLogin date
11/01/21
11/01/21
21/01/21
32/01/21
15/01/21
29/01/21
410/01/21

 

I am interested in calculating retained customers. For example, this could be how many members log in twice in seven days. The answer using this data would be one (user id=1).  Ideally, I would like to vary the time period e.g. how many members login twice within 14 days. I am struggling with what DAX formula to use. I would appreciate any help someone can provide. 

 

Many thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

You can use DISTINCTCOUNT to count how many distinct days a user has logged in. Depending on how you want to view the data, you could either setup a week start calculated column (https://bielite.com/blog/week-start-date-power-bi-dax/) and view like this - 

PowerBIUserNZ_0-1623726067446.png

Or setup a date table and create a measure with CALCULATE and FILTER (on the date table) to get users with two logins for a selected week. Bear in mind DAX does not have time intelligence for week like it does with year, quarter, and month so getting week-to-date data is more difficult- https://www.sqlbi.com/articles/week-based-time-intelligence-in-dax/

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

You can use DISTINCTCOUNT to count how many distinct days a user has logged in. Depending on how you want to view the data, you could either setup a week start calculated column (https://bielite.com/blog/week-start-date-power-bi-dax/) and view like this - 

PowerBIUserNZ_0-1623726067446.png

Or setup a date table and create a measure with CALCULATE and FILTER (on the date table) to get users with two logins for a selected week. Bear in mind DAX does not have time intelligence for week like it does with year, quarter, and month so getting week-to-date data is more difficult- https://www.sqlbi.com/articles/week-based-time-intelligence-in-dax/

Ashish_Mathur
Super User
Super User

Hi,

WHat do you mean by "I would like to vary the time period"?  In the slicer, will you be selecting a particular date?  Show data spanning more than 7 days and on that data show the expected result clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi Ashish, 

 

I have just edited the post. By vary the time period, I would like to change the period x in this question "how many members log in twice within x days of first log in"? Does that help?

I am still not clear.  If a customer (Cust 1) logs in on January 5, January 14, January 23 and January 26, then what should the answer be if we select the time span as 7 days?  Please take a few cases to illustrate different cases very clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

My apologies. 

 

Using your example, the answer would be no. Here are a few more examples. 

 

How many users log in twice in seven days?

Cust 1 logs in Jan 5th, Jan 6th and Jan 14th. Cust  2 logs in Jan 5th, Jan 6th and Jan 14th. The answer is two. 

 

Cust 1 logs in Jan 5th, Jan 6th and Jan 14th. Cust  2 logs in Jan 5th and Jan 14th. The answer is one.

 

Cust 1 logs in Jan 5th, and Jan 14th. Cust  2 logs in Jan 5th and Jan 14th. The answer is zero.

Hi,

So you want to see whether a person's second log-in is within 7 days of he first log-in (not of subsequent log-ins).  So if a Customer logged in on Jan 5, Jan 13, Jan 16 then this person would not be counted because the difference between the first and second log-in is more than 7 days.  Am i correct?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi Ashish, 

 

Apologies for the late reply. Yes, that is correct. 

 

Cheers

 

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.