Reputation: 113
I have a query that pulls a list of user engements of the form: Date, user name, campaign_id,
There is uniqueness in the campaign_id in a sense that a user clicks only once per day per campaign_id (campaign id cant be logged twice for the same user within a day)
My question is how do I pull a list of unique active users per month? A user can be logged more than once for different campaigns and different days.
customEvents
| extend rTimeStamp = todatetime(customDimensions.timeStamp),
username = tolower(tostring(customDimensions.username)),
event = name, item_uid = tostring(customDimensions.itemId)
| extend rTimeStamp = todatetime(substring(tostring(rTimeStamp), 0, 10))
| where event == 'click'
| project rTimeStamp, username, event, item_uid
| summarize arg_min(rTimeStamp, *) by item_uid, username
| summarize click_count = countif(event == 'click') by rTimeStamp, username, item_uid
| order by rTimeStamp
Upvotes: 11
Views: 21405
Reputation: 743
Using the "distinct" operator:
...
| distinct username
If you'd like a list of distinct users per month, also possible with summarize:
...
| summarize by username, bin(rTimeStamp, 30d)
Upvotes: 13