The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I'm trying to replicate in powerbi what I have in the excel screenshot. I want to find the time difference between two adjacent dates and output the time difference in seconds to the next column.
Solved! Go to Solution.
Hi @Anonymous ,
You could try to add an index column and use the function of DATEDIFF to calculate. I created a calculated column to implement it that you can have a try.
let Source = Excel.Workbook(File.Contents("C:\Users\xueding\Desktop\DateTime.xlsx"), null, true), Sheet2_Sheet = Source{[Item="Sheet2",Kind="Sheet"]}[Data], #"Promoted Headers" = Table.PromoteHeaders(Sheet2_Sheet, [PromoteAllScalars=true]), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"DateTime", type datetime}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1) in #"Added Index"
Column = var last = CALCULATE(MAX('Table'[DateTime]),FILTER('Table','Table'[Index] =EARLIER( 'Table'[Index]) -1)) return DATEDIFF(last,MAX('Table'[DateTime]),SECOND)
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
You could try to add an index column and use the function of DATEDIFF to calculate. I created a calculated column to implement it that you can have a try.
let Source = Excel.Workbook(File.Contents("C:\Users\xueding\Desktop\DateTime.xlsx"), null, true), Sheet2_Sheet = Source{[Item="Sheet2",Kind="Sheet"]}[Data], #"Promoted Headers" = Table.PromoteHeaders(Sheet2_Sheet, [PromoteAllScalars=true]), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"DateTime", type datetime}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1) in #"Added Index"
Column = var last = CALCULATE(MAX('Table'[DateTime]),FILTER('Table','Table'[Index] =EARLIER( 'Table'[Index]) -1)) return DATEDIFF(last,MAX('Table'[DateTime]),SECOND)
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I think the standard advice for doing calculations involving adjacent cells is to do it in Excel....Excel is designed for it, Power BI is not. Then load your data into Power BI to use its features for analysis.
Help when you know. Ask when you don't!
User | Count |
---|---|
77 | |
76 | |
36 | |
31 | |
29 |
User | Count |
---|---|
93 | |
79 | |
57 | |
48 | |
48 |