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.
I have the following table:
Nr position time
1 in 12:23:10
2 in 12:25:19
1 out 12:28:59
3 in 13:00:00
2 out 13:02:10
and want to compute the time difference between in and out of each number, so that i have in this example:
Nr diff
1 00:05:49
2 00:06:51
3 null (or another text like "in")
how can i do this ?
thank you very much
Solved! Go to Solution.
You're looking for the Pivot function.
Screenshots:
The line of M:
#"Added Difference" = Table.AddColumn(#"Pivoted Column", "Diff", each [out] - [in]),
Hi @seb_BMW,
Alternatively, you can achieve this in DAX.
Create a calculated table based on below formula.
new table = SUMMARIZE ( 'time difference', 'time difference'[Nr], "time diff", DATEDIFF ( MIN ( 'time difference'[time] ), MAX ( 'time difference'[time] ), SECOND ) )
Add a calculated column in order to format the time difference.
Column =
IF (
'new table'[time diff] = 0,
BLANK (),
INT ( 'new table'[time diff] / 3600 )
& ":"
& INT ( MOD ( 'new table'[time diff], 3600 ) / 60 )
& ":"
& MOD ( MOD ( 'new table'[time diff], 3600 ), 60 )
)
Hi @seb_BMW,
Have you worked it out? If so, would you please mark the corresponding reply as an answer? If you still have any concern, please feel free to ask.
Regards,
Yuliana Gu
Hi @seb_BMW,
Alternatively, you can achieve this in DAX.
Create a calculated table based on below formula.
new table = SUMMARIZE ( 'time difference', 'time difference'[Nr], "time diff", DATEDIFF ( MIN ( 'time difference'[time] ), MAX ( 'time difference'[time] ), SECOND ) )
Add a calculated column in order to format the time difference.
Column =
IF (
'new table'[time diff] = 0,
BLANK (),
INT ( 'new table'[time diff] / 3600 )
& ":"
& INT ( MOD ( 'new table'[time diff], 3600 ) / 60 )
& ":"
& MOD ( MOD ( 'new table'[time diff], 3600 ), 60 )
)
You're looking for the Pivot function.
Screenshots:
The line of M:
#"Added Difference" = Table.AddColumn(#"Pivoted Column", "Diff", each [out] - [in]),
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
85 | |
67 | |
59 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |