We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello,
I am working with some IT Incident Data and we are looking to get a field created for the average time between the tickets created date and resolved date. I have done some research and I have a few steps done but I'm having trouble with the actual averaging part.
We have "Created On" and "ResolvedDateTime". I was able to find a formula online to find the date difference between the two
if [ResolvedDateTime] is null then Duration.Days(DateTime.LocalNow()-[Created On]) else Duration.Days([ResolvedDateTime]-[Created On])
This works great. It shows a whole number difference between the two dates. Ideally I would like to get the difference down to days, hours, and minutes but that can wait. Now I'm trying to find the average amount of time from this new 'Date Difference" column. I did some additional research and found a similar post on this forum and I think I am close.
Any ideas on how I can get either my formula to change the zeros, or get a similar 2nd formula that knows what to do with the zeros? In a similar vein, I would like the "Date Difference" to show Days, Hours, and Minutes if possible. Not entirely sure how much that changes the formula but wanted to include that just in case.
Hi @Anonymous
I'm not sure why that custom column didn't work. Instead I created a column using your IF logic and then calculated days based on that date.
let
Source = Excel.Workbook(File.Contents("C:\Power_BI\PBI Community\Find average duration between two dates\SampleData.xlsx"), null, true),
Tickets_Sheet = Source{[Item="Tickets",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Tickets_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"TicketID", Int64.Type}, {"Created On", type date}, {"x", Int64.Type}, {"ResolvedDateTime", type date}, {"Other field", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"x"}),
#"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each if [ResolvedDateTime] = null then DateTime.LocalNow() else [ResolvedDateTime]),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type date}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type1", "Days", each Duration.Days( [Custom] - [Created On] )),
#"Changed Type2" = Table.TransformColumnTypes(#"Added Custom1",{{"Days", Int64.Type}}),
#"Removed Columns1" = Table.RemoveColumns(#"Changed Type2",{"Custom"})
in
#"Removed Columns1"
Ignore anything above #"Added Custom".
Let me know if you have any questions.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 56 | |
| 40 | |
| 36 | |
| 18 | |
| 18 |
| User | Count |
|---|---|
| 70 | |
| 67 | |
| 38 | |
| 34 | |
| 23 |