Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi All,
Some where in Community, I found a DAX code and used it to build one for my requirement . For some reason, I am not able to acheive what I need.
Solved! Go to Solution.
Hi @Anonymous
Change the queries as below
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Time to Resolve sec", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Sum", each List.Sum(#"Changed Type"[Time to Resolve sec])), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Count of Incident ID", each List.NonNullCount(List.Distinct(#"Added Custom"[Incident ID]))), #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Average", each [Sum]/[Count of Incident ID]), #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Hours", each Number.RoundDown([Average]/3600)), #"Added Custom4" = Table.AddColumn(#"Added Custom3", "Minutes", each Number.RoundDown(([Average]-3600*[Hours])/60)), #"Added Custom5" = Table.AddColumn(#"Added Custom4", "Seconds", each Number.RoundUp(Number.Mod([Average]-3600*[Hours],60))), #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Added Custom5", {{"Hours", type text}, {"Minutes", type text}, {"Seconds", type text}}, "en-US"),{"Hours", "Minutes", "Seconds"},Combiner.CombineTextByDelimiter(":", QuoteStyle.None),"Merged") in
If #"Added Custom5" doesn't use Number.RoundUp, it will show 5.38 for seconds, then after merging columns, it can't change type to duration, it would throw an error.
Best Regards
Maggie
Hi @Anonymous
Open Edit queries,
Add custom columns
sum=List.Sum(#"Changed Type"[time to resolve sec]) count of id=List.NonNullCount(List.Distinct(#"Added Custom"[id])) average=[sum]/[count of id] hours=Int64.From([average]/3600) minutes=Int64.From(([average]-3600*[hours])/60) seconds=Number.Mod([average]-3600*[hours],60)
click on "setting" icon to open the window to see what steps i applied.
Merge columns:
select "hours", "minutes","seconds" at the same time, then select "merge columns"
Change "Merged" to Type "duration"
Close&&apply
In report view, change the data format to "time" for the "Merged" column
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Maggie,
Thanks for your reply. I followed all the steps given by you . But I am facing an issue with Minutes and Seconds Columns as they are appearing in negative values. Could you please check the screen shot i have attached and advise me some thing ?
Hi @Anonymous
Please show me the total seconds you use to create "hours","minutes" and "seconds"
Hi Maggie,
Please find the screen shot . Below is the column I used in calculations.
I have followed same steps which you have given . See the Columns i have created below.
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Time to Resolve sec", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Sum", each List.Sum(#"Changed Type"[Time to Resolve sec])),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Count of Incident ID", each List.NonNullCount(List.Distinct(#"Added Custom"[Incident ID]))),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Average", each [Sum]/[Count of Incident ID]),
#"Added Custom3" = Table.AddColumn(#"Added Custom2", "Hours", each Int64.From([Average]/3600)),
#"Added Custom4" = Table.AddColumn(#"Added Custom3", "Minutes", each Int64.From(([Average]-3600*[Hours])/60)),
#"Added Custom5" = Table.AddColumn(#"Added Custom4", "Seconds", each Number.Mod([Average]-3600*[Hours],60)),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Added Custom5", {{"Hours", type text}, {"Minutes", type text}, {"Seconds", type text}}, "en-US"),{"Hours", "Minutes", "Seconds"},Combiner.CombineTextByDelimiter(":", QuoteStyle.None),"Merged")
in
Hi @Anonymous
Change the queries as below
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Time to Resolve sec", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Sum", each List.Sum(#"Changed Type"[Time to Resolve sec])), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Count of Incident ID", each List.NonNullCount(List.Distinct(#"Added Custom"[Incident ID]))), #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Average", each [Sum]/[Count of Incident ID]), #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Hours", each Number.RoundDown([Average]/3600)), #"Added Custom4" = Table.AddColumn(#"Added Custom3", "Minutes", each Number.RoundDown(([Average]-3600*[Hours])/60)), #"Added Custom5" = Table.AddColumn(#"Added Custom4", "Seconds", each Number.RoundUp(Number.Mod([Average]-3600*[Hours],60))), #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Added Custom5", {{"Hours", type text}, {"Minutes", type text}, {"Seconds", type text}}, "en-US"),{"Hours", "Minutes", "Seconds"},Combiner.CombineTextByDelimiter(":", QuoteStyle.None),"Merged") in
If #"Added Custom5" doesn't use Number.RoundUp, it will show 5.38 for seconds, then after merging columns, it can't change type to duration, it would throw an error.
Best Regards
Maggie
Hi Team,
I have tried few more . Please see below.
Now the last measure "Hours" which is in decimal format should be converted to HH:MM format and the expected value is 05:50 (5 hours 50 mins ) . Please help me .
I have tried the below formulae , but it didnt worked .
User | Count |
---|---|
123 | |
77 | |
62 | |
50 | |
48 |
User | Count |
---|---|
175 | |
125 | |
61 | |
60 | |
58 |