Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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
UserName | TimeStamp | Status |
abc | 2025-03-20 01:33 | Login |
abc | 2025-03-20 06:11 | Logoff |
abc | 2025-03-20 06:23 | Login |
abc | 2025-03-20 09:48 | Logoff |
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 |
abc | 2025-03-22 22:11 | Login |
abc | 2025-03-23 09:48 | Logoff |
def | 2025-03-20 08:33 | Login |
def | 2025-03-21 09:33 | Logoff |
def | 2025-03-22 09:34 | Login |
def | 2025-04-01 08:33 | Login |
def | 2025-04-02 16:33 | Logoff |
My expected result for user abc
Login | Logoff |
2025-03-20 22:07 | 2025-03-21 10:04 |
2025-03-21 22:08 | 2025-03-23 09:48 |
Thank you in advance
Solved! Go to Solution.
pls see if this is what you want
Proud to be a Super User!
why we don't calculate the time for the first 5 rows?
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?
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
Login | Logoff |
2025-03-20 22:07 | 2025-03-21 10:04 |
2025-03-21 22:08 | 2025-03-23 09:4 |
Its possible to have multiple login and logout for same user in the same session
Thanks
pls see if this is what you want
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
what do you mean cross the midnight? what's the time period for midnight?
Proud to be a Super User!
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.
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
pls see if this is what you want
Proud to be a Super User!
you are welcome
Proud to be a Super User!
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! 🙂
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
78 | |
75 | |
58 | |
36 | |
33 |
User | Count |
---|---|
100 | |
62 | |
56 | |
47 | |
41 |