Forum Discussion
Average time grouped by column
Hi everyone!
I'm working with time (minutes and seconds played) and would like to get the average time for every distinct pair of players. I tried the following formula but didn't work because it's said that the variable can't get an unique value.
How could I get the average value? I add a Drive link to the Excel file with the Raw Data and the expected result, to try to help to get the result.
Link with the Raw Data and Expected Result: Link with file
Thank you in advance.
Tested measure (not working):
Average Time =
var IntCourt = 'Table'[Int_OnCourt]
Return
AVERAGEX(
FILTER(ALL('Table'), 'Table'[Int_OnCourt] = IntCourt),
'Table'[TimeOnCourt])
6 Replies
- amitchandakSuper User
sfernamer , Try like
Avg time =
var _time = AVERAGEX(Table,HOUR(Table[TimeOnCourt])*3600+Minute(Table[TimeOnCourt])*60 +SECOND(Table[TimeOnCourt]))
return
time(QUOTIENT(_time,3600) ,QUOTIENT(Mod(_time,3600),60),mod(Mod(_time,3600),60))- sfernamerHelper III
Thank you for your time, amitchandak , but this formula didn't work for my case. The one taht worked more or less is the one posted for the other user. Thank you anyway for your help and your time. 🙂
- AhmedxSuper User
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
https://1drv.ms/u/s!AiUZ0Ws7G26Rh3ONItvQtPlETpMW?e=dW9liP- sfernamerHelper III
Hi Ahmedx
Your answer worked for almost all cases but there are cases where the result is "00:00:60" instead of "00:01:00", Idk why is not rounding this number but, if I wanna convert the text result into time, it's not working for these cases. For the other ones, it's working perfectly.
- AhmedxSuper User
you can create an example where the measure counts incorrectly?