Hi, I’d like to calculate the total of watching time and the average of watching time per username but the result of the average seems incorrect. Thanks in advance !
avgOver(dateDiff({join_stream_time}, {leave_stream_time}, ‘HH’), [{pub_login_name}], PRE_AGG)
ErikG
October 12, 2023, 6:57am
2
Hi @thecuon119 ,
what is the result when you calculate the diff on username level? e.g. your first row.
Maybe you can create a new field “time_diff” and check the if calculation is right.
BG
sorry but how come i perform that diff on username level ?
ErikG
October 12, 2023, 7:47am
5
Are there more than one entry for the “pub_login_name”? Because currently its a SUM.
Could you try to use it as dimension field?
pub_login_name is in string type, the sum of test 1 is the sum of the datediff above
pub_login_name = username in athena
ErikG
October 12, 2023, 8:12am
8
But there is only one row? Becaus it seem not. Somewhere it is grouped and summarizied.
ErikG
October 12, 2023, 8:18am
11
Could you pls move the “test1” into “Group by”?
I knew it, i gotta use max :max(dateDiff({join_stream_time}, {leave_stream_time}, ‘HH’), [{pub_login_name}])
ErikG
October 12, 2023, 8:24am
13
But that shows me you have more than one value. If you change the aggregation from Sum to Count, in the old simple dateDiff version you should see it.
ah yeah, here it is
it is test1: dateDiff({join_stream_time}, {leave_stream_time}, ‘HH’)
1 Like
ErikG
October 12, 2023, 8:30am
15
Maybe you missed a filter on the table? I see you have a date control.
yeah but date control isn’t related in this case, i just want to calculate the total watching time
ErikG
October 12, 2023, 8:35am
17
But you have to be careful with Max, because Max doesn’t have to be the current/last one.
Idk why it’s transparently null but result is still (7+7+7+7…) = 49
ErikG
October 12, 2023, 8:38am
20
You could use all dimension fields and check where the 7 records are located.