Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi, I have a table with a column of date/time timestamps called "Time Stamp" and I want to subtract a duration in minutes (on the same row in column Minutes) from the timestamp. How can this be done? Desired column shown below. Many thanks
Desired Column from mcode calculation | ||
Time stamp | Minutes | timestamp column subtracted Minutes column |
31/08/2023 17:59:42 | 12.5 | 31/08/2023 17:47:12 |
31/08/2023 09:56:04 | 13.00 | 31/08/2023 09:43:04 |
31/08/2023 19:24:37 | 1.25 | 31/08/2023 19:23:22 |
Solved! Go to Solution.
Hi @rockingmark
If you divide [Minutes] by (24 * 60), the result is the fraction of a day which converts to a duration.
let
Source = SourceTable,
#"Added Custom" = Table.AddColumn(Source, "Days", each [Minutes] / ( 24 * 60 )),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Days", type duration}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type", "New Timestamp", each [Time stamp] - [Days]),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom1",{{"New Timestamp", type datetime}})
in
#"Changed Type1"
Subtract minutes from timestamp.pbix
Hi @rockingmark
If you divide [Minutes] by (24 * 60), the result is the fraction of a day which converts to a duration.
let
Source = SourceTable,
#"Added Custom" = Table.AddColumn(Source, "Days", each [Minutes] / ( 24 * 60 )),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Days", type duration}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type", "New Timestamp", each [Time stamp] - [Days]),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom1",{{"New Timestamp", type datetime}})
in
#"Changed Type1"
Subtract minutes from timestamp.pbix
Cool Thanks, I was missing that you can convert minutes to duration so your example massively helped me
Do you want the minutes column e.g. 12.5 to be a duration of 12 minutes 30 secs?
If so,
Number.RoundDown([Minutes])
will give the whole minutes.
60 * Number.Mod([Minutes],1)
will give the seconds.
You use those to construct a #duration() https://learn.microsoft.com/en-us/powerquery-m/sharpduration and subtract it from the Time Stamp column
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
69 | |
68 | |
40 | |
29 | |
26 |
User | Count |
---|---|
89 | |
49 | |
44 | |
38 | |
37 |