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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Yacine2025
Frequent Visitor

Need help

Hi everyone

I'm New in power bi and i need help to resolve this case. I want to calculate session duration between login and logout for each user per login date knowing that status can contains multiple login logout and session can cross midnight.

 

Here is my data

UserNameTimeStampStatus
abc2025-03-20 01:33Login
abc2025-03-20 06:11Logoff
abc2025-03-20 06:23Login
abc2025-03-20 09:48Logoff
abc2025-03-20 22:07Login
abc2025-03-20 22:33Logoff
abc2025-03-20 22:34Login
abc2025-03-21 02:55Logoff
abc2025-03-21 02:56Login
abc2025-03-21 10:04Logoff
abc2025-03-21 22:08Login
abc2025-03-22 09:46Logoff
abc2025-03-22 22:11Login
abc2025-03-23 09:48Logoff
def2025-03-20 08:33Login
def2025-03-21 09:33Logoff
def2025-03-22 09:34Login
def2025-04-01 08:33Login
def2025-04-02 16:33Logoff

 

 

My expected result for user abc

LoginLogoff
2025-03-20 22:072025-03-21 10:04
2025-03-21 22:082025-03-23 09:48
  

 

 

Thank you in advance

1 ACCEPTED SOLUTION

@Yacine2025 

pls see if this is what you want

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

18 REPLIES 18
ryan_mayu
Super User
Super User

why we don't calculate the time for the first 5 rows?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu 

I just ignore them in my post because the login is in the Last day but yes i want to do the same calculate for every user every day 

Thanks for your Quick reply

still not clear about the logic. could you pls update the sample data and expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu 

This is my row data

UserName TimeStamp Status
abc 2025-03-20 22:07 Login
abc 2025-03-20 22:33 Logoff
abc 2025-03-20 22:34 Login
abc 2025-03-21 02:55 Logoff
abc 2025-03-21 02:56 Login
abc 2025-03-21 10:04 Logoff
abc 2025-03-21 22:08 Login
abc 2025-03-22 09:46 Logoff

The expected result is like this

 

LoginLogoff
2025-03-20 22:072025-03-21 10:04
2025-03-21 22:082025-03-23 09:4

Its possible to have multiple login and logout for same user in the same session 

Thanks 

 

 

 

 

@Yacine2025 

pls see if this is what you want

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu ,

 

Its not the expected result

 

This is my goal, the session cross midnight

Login

2025-03-20 22:07

Logoff

2025-03-21 10:04

 

Login

2025-03-21 22:08

Logoff

2025-03-23 09:4

 

Thanks in advance

@Yacine2025 

what do you mean cross the midnight? what's the time period for midnight?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




  • The user starts at 22h07 and finish at 10h4 am the day after in this case i need to calculate the duration of his session between 22h07 and 10h4am knowing that in others cases it may have multiple login and logoff that i want to ignore.

Thanks

Hi @Yacine2025 ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


Thank you.

Hi @Yacine2025 ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

 

what i mean is the standard creteria for all the situaion. what if logout at 9 am and login at 10 am again? what if logout at 10 am and login at 11 am? What I want is the start time and end time of midnight.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu 
There are users who have a working day from 8am to 5pm and others who start at 9pm and finish at 5am so I would like to determine the timestamps of the first login and the last logout to calculate the total duration per shif
thanks

@Yacine2025 

pls see if this is what you want

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu , thank you so much its working

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu , sorry for the delay, i will try your solution tomorrow

 

Thanks 

SamanthaPuaXY
Helper II
Helper II

Hi @Yacine2025 

You could filter to get a table with just Log off details and a table with just Login in details. Sort them according to timestamp, index them and do a merge with the Index to get the respective Log off details.

 

This is assuming the data is clean and each log in will have a respective log off, vice versa.

Do give a kudos if this helps! 🙂

Hi @SamanthaPuaXY 

Thanks for your reply, i have a multiple login logout per session so for the moment its difficult to pair login logout and some sessions of users cross midnight.

 

Thanks

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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