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

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

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.