title: How do i perform a distinct statement in azure applications insights?
body: <p>I have a query that pulls a list of user engements of the form:
  Date, user name, campaign_id,</p>
  
  <p>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) </p>
  
  <p>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.</p>
  
  <pre><code>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
  </code></pre>