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

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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors