Forum Discussion
ankasani
Microsoft
Feb 15, 2023How to use multiple sliding_window_counts in a single query
Hi Team, I am using a query like below let Start = startofday(ago(60d)); let End = startofday(now()); let window=30d; //MAU 30d, WAU 7d, DAU 1d let bin = 1d; customEvents | where timestamp >=...
- Mar 16, 2023
ankasani , you can try something like this
let Start = startofday(ago(60d)); let End = startofday(now()); let MAUwindow=30d; //MAU 30d, WAU 7d, DAU 1d let WAUwindow=7d; let DAUwindow=1d; let bin = 1d; let filteredEvents= materialize (customEvents | where timestamp >= Start and timestamp <= End | project user_Id, timestamp); let MAUcounts=filteredEvents | evaluate sliding_window_counts(user_Id, timestamp, Start, End, MAUwindow, bin) | project timestamp, mau=Dcount; let WAUcounts=filteredEvents | evaluate sliding_window_counts(user_Id, timestamp, Start, End, WAUwindow, bin) | project timestamp, wau=Dcount; let DAUcounts=filteredEvents | evaluate sliding_window_counts(user_Id, timestamp, Start, End, DAUwindow, bin) | project timestamp, dau=Dcount; MAUcounts | join kind=inner WAUcounts on timestamp | join kind=inner DAUcounts on timestamp | project timestamp, mau, wau, dau | render timechart with (ysplit=panels)
SuryaJ
Microsoft
Mar 16, 2023ankasani , you can try something like this
let Start = startofday(ago(60d));
let End = startofday(now());
let MAUwindow=30d; //MAU 30d, WAU 7d, DAU 1d
let WAUwindow=7d;
let DAUwindow=1d;
let bin = 1d;
let filteredEvents= materialize (customEvents
| where timestamp >= Start and timestamp <= End
| project user_Id, timestamp);
let MAUcounts=filteredEvents
| evaluate sliding_window_counts(user_Id, timestamp, Start, End, MAUwindow, bin)
| project timestamp, mau=Dcount;
let WAUcounts=filteredEvents
| evaluate sliding_window_counts(user_Id, timestamp, Start, End, WAUwindow, bin)
| project timestamp, wau=Dcount;
let DAUcounts=filteredEvents
| evaluate sliding_window_counts(user_Id, timestamp, Start, End, DAUwindow, bin)
| project timestamp, dau=Dcount;
MAUcounts
| join kind=inner WAUcounts on timestamp
| join kind=inner DAUcounts on timestamp
| project timestamp, mau, wau, dau
| render timechart with (ysplit=panels)