question

rupinderkhatkar avatar image
rupinderkhatkar asked

Summing duration

I am trying to figure out how to sum duration per run. So ideally the columns I would like to see would be day, count of players and sum of duration runs (time). This is what I have so far, but I have an error: ['events.all'] | where FullName_Name == "on_run_ended_by_dying" | where Timestamp > ago(10d) | project format_datetime(Timestamp,'yyyy-MM-dd'),Entity_Id,FullName_Name,EventData | summarize Players=dcount(Entity_Id), Duration=sum(EventData._RunDuration) | extend sumBy = tolong(EventData._RunDuration) | render columnchart

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Neils Shi avatar image
Neils Shi answered

Since I didn't find the event "on_run_ended_by_dying" in PlayStream Event Model reference, this appears to be a custom event that you created. And you said that the columns you would like to see the day, count of players and sum of duration runs (time). You can refer to my testing code.

 ['events.all']
  | where FullName_Name == "on_run_ended_by_dying"
  | where Timestamp > ago(10d)
  | project format_datetime(Timestamp,'yyyy-MM-dd'),Entity_Id,FullName_Name,EventData
  | summarize Players=dcount(Entity_Id), Duration=sum(toint(EventData._RunDuration)) by Timestamp
  |render columnchart

5648-test1.png


test1.png (13.6 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

rupinderkhatkar avatar image
rupinderkhatkar answered

Thank you, sometimes the query works and sometimes not. I changed the render to barchart and seems ok now. How can I make it so the where clause can have 2 events including this one: on_run_ended_by_winning Would it just be another line of FullName_Name = the above?

Also I tried dividing the duration by players and no luck: ['events.all'] | where FullName_Name == "on_run_ended_by_dying" | where Timestamp > ago(10d) | project format_datetime(Timestamp,'yyyy-MM-dd'),Entity_Id,FullName_Name,EventData | summarize Players=dcount(Entity_Id), Duration=sum(toint(EventData._RunDuration)) by Timestamp | extend DurationPerPlayer=Duration/Players |render barchart

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.