Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hello guys,
Supposed I have the following data of users, each time they logged in and logged out:
User LoggingType Date
1 In 2018-10-05 13:18:26.900
1 Out 2018-10-05 13:18:54.353
1 In 2018-10-05 13:19:23.637
1 Out 2018-10-05 13:20:03.887
2 In 2018-10-05 13:21:25.887
2 Out 2018-10-05 13:22:01.247
3 In 2018-10-10 18:24:33.867
3 Out 2018-10-10 18:25:35.443
How do I create another column illustrating how long an user was logged in for a session? For example, here's what I wish to see:
User LoggingType Date Duration
1 In 2018-10-05 13:18:26.900
1 Out 2018-10-05 13:18:54.353 2018-10-05 13:18:54.353 - 2018-10-05 13:18:26.900
1 In 2018-10-05 13:19:23.637
1 Out 2018-10-05 13:20:03.887 2018-10-05 13:20:03.887 - 2018-10-05 13:19:23.637
2 In 2018-10-05 13:21:25.887
2 Out 2018-10-05 13:22:01.247 2018-10-05 13:22:01.247 - 2018-10-05 13:21:25.887
3 In 2018-10-10 18:24:33.867
3 Out 2018-10-10 18:25:35.443 2018-10-10 18:25:35.443 - 2018-10-10 18:24:33.867
Solved! Go to Solution.
Hi @Anonymous ,
Based on my test, you could refer to below steps:
Add index for your data in query editor:
Apply it and create below formula:
Column = var a=[Index]-1 return CALCULATE(MAX(Table1[Date]),FILTER('Table1','Table1'[Index]=a))
Result:
Now you could use the [Date] column to minus the [Column].
Regards,
Daniel He
Hi @Anonymous ,
Based on my test, you could refer to below steps:
Add index for your data in query editor:
Apply it and create below formula:
Column = var a=[Index]-1 return CALCULATE(MAX(Table1[Date]),FILTER('Table1','Table1'[Index]=a))
Result:
Now you could use the [Date] column to minus the [Column].
Regards,
Daniel He
Thanks this is what I was looking for
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
33 | |
32 | |
27 | |
23 |
User | Count |
---|---|
40 | |
33 | |
19 | |
18 | |
16 |