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.

1 Answer

·
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)
11 comments
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 commented ·

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

0 Likes 0 ·
Neils Shi avatar image Neils Shi rupinderkhatkar commented ·

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?

To query two events, you can refer to:

 ['events.all']
 | where FullName_Name == "on_run_ended_by_dying" or FullName_Name == "on_run_ended_by_winning"

Also I tried dividing the duration by players and no luck

Do you mean the "DurationPerPlayer=Duration/Players" doesn't work? It works fine in my test. 5675-testkusto.png

0 Likes 0 ·
testkusto.png (46.7 KiB)
rupinderkhatkar avatar image rupinderkhatkar Neils Shi commented ·

Ok thanks, this appears to work now. When I combine the 2 event names, the duration goes into minus figures, why would that be?

0 Likes 0 ·
Show more comments
rupinderkhatkar avatar image rupinderkhatkar commented ·

I would love to know how to make a more complicated query. I want to track number of sessions as an incremental count and then from this count how many runs players are doing ie in session 1 on average players are winning 5 runs. I have this for sessions in general:

['events.all'] | where FullName_Name == "client_session_start" | where Timestamp > ago(10d) | project format_datetime(Timestamp,'yyyy-MM-dd'),Entity_Id,FullName_Name | summarize Players=dcount(Entity_Id), NoSessions=count() by Timestamp | extend AverageSession=NoSessions/Players | render columnchart

I would like to add this event (on_exiting_to_main_menu_from_hub) along with this parameter (AmountOfRunsWon) - this here would allow me to sum the runs

0 Likes 0 ·
Neils Shi avatar image Neils Shi rupinderkhatkar commented ·

Can you tell me more about " I want to track number of sessions as an incremental count and then from this count how many runs players are doing ie in session 1 on average players are winning 5 runs." If you want to add the event "on_exiting_to_main_menu_from_hub" along with this parameter "AmountOfRunsWon", then sum the runs. You can refer to my testing code.

 ['events.all']
 | where FullName_Name == "client_session_start" or FullName_Name == "on_exiting_to_main_menu_from_hub"
 | where Timestamp > ago(1d)
 | project format_datetime(Timestamp,'yyyy-MM-dd'),Entity_Id,FullName_Name,EventData
 | summarize Players=dcount(Entity_Id)/2, NoSessions=count()/2,RunSum=sum(toint(EventData.AmountOfRunsWon))by Timestamp
 | extend AverageSession=NoSessions/Players
 | render columnchart

5758-ex3.png

0 Likes 0 ·
ex3.png (46.0 KiB)
rupinderkhatkar avatar image rupinderkhatkar Neils Shi commented ·

Thank you, with the above you have it showing per day/date. I would prefer to have on the x axis, the session number ie session 1-10. Then within each session, what was the total sessions in session 1, total sessions in session 2 and so on. Also to count the players seen at each session then I can sum the runsWon, so ideally each session would 3 bar charts - 'total sessions' (aka number of total sessions) , total players, sum of runsWon.

0 Likes 0 ·
Show more comments

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.