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

Calculate "New Users" based on last login

Very new to DAX, this may be a simple task.

I have a table with Conversation ID, USerID, and Login TimeStamp. I am trying to show a trending chart of users, by Login TS.

 

 

Conversation IDUser IDTimeStamp
 123SamMarch 10, 2020 23:45:00
123SamMarch 10, 2020 23:59:00
456VimesDecember 11, 2019 12:34:00
789VimesDecember 12, 2019 07:36:00
567VimesJanuary 10, 2020 10:34:00

 

 

My calculation to show "New Users" requires me to identify the unique users who have had at least 30 hours expired since their last login. So, for the example above, Sam would not be considered a New User for March 10. Vimes would not be a new user for December 12 (since it has been less than 30 hours since his last login on December 11), but Vimes would be a new user for January 10. How can I achieve this? I was thinking of adding a calculated column with "Previous TS" for each user, and then take the difference between the two TS, but so far have been unable to achieve this.

 

Thank you!

 

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

A column for the hours since last login:

HoursSinceLastLogin = VAR _user = TableCons[User ID]
                      VAR _time = TableCons[TimeStamp] 
RETURN
   DATEDIFF( CALCULATE(MAX(TableCons[TimeStamp]), FILTER(TableCons, TableCons[User ID] = _user && TableCons[TimeStamp] < _time)), TableCons[TimeStamp] , HOUR)

View solution in original post

1 REPLY 1
HotChilli
Super User
Super User

A column for the hours since last login:

HoursSinceLastLogin = VAR _user = TableCons[User ID]
                      VAR _time = TableCons[TimeStamp] 
RETURN
   DATEDIFF( CALCULATE(MAX(TableCons[TimeStamp]), FILTER(TableCons, TableCons[User ID] = _user && TableCons[TimeStamp] < _time)), TableCons[TimeStamp] , HOUR)

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.