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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Bergh
Helper II
Helper II

Calculate time diff in same column

Hello. I have a problem, I want to calcute time diff in a column. And then I want to filter everything over 20 sec.Time.jpg

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Bergh 

 

Do you want to calculate the difference between current row with the next row? All rows are above 20 sec...or you want something different?

Vera_33_0-1617267033207.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrTUNzDWNzIwMlQwtLAyNFeK1UEVNLcyMcUQNMMuaGSCIWhqZWqpFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type datetime}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each [nextrow = try #"Added Index"{[Index]+1}[Column1] otherwise [Column1],
comp = ([Column1]-nextrow)> #duration(0,0,0,20)][comp])
in
    #"Added Custom"

 

View solution in original post

2 REPLIES 2
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Bergh 

 

Do you want to calculate the difference between current row with the next row? All rows are above 20 sec...or you want something different?

Vera_33_0-1617267033207.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrTUNzDWNzIwMlQwtLAyNFeK1UEVNLcyMcUQNMMuaGSCIWhqZWqpFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type datetime}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each [nextrow = try #"Added Index"{[Index]+1}[Column1] otherwise [Column1],
comp = ([Column1]-nextrow)> #duration(0,0,0,20)][comp])
in
    #"Added Custom"

 

Thanks Vera_33 it works fine for me!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.