Unique Distinct ID by Day and Event

  • 14 November 2020
  • 1 reply

Badge +2

Hi there


I’m trying to get a list of distinct_id’s filtered by an event, and unique per day. So I expect to see duplicate distinct_id’s only when the date changes. My code below delivers a list of distinct_ids and the desired parameters, but I can’t get it to group by date so there are no duplicates.

Some of my grouping attempts are commented out. They are based on what I could find as an example at the bottom of the following page:

In using that example, I found that the additional properties I’m asking for, became unreadable. 

I hope that makes sense, my code is below.

Thank you!



var File_Opened = [{event: "File Opened"}] ;

function getYearMonth(date) {   return date.toISOString().substr(0, 10); }

function main() {   return Events({     from_date: '2020-10-29', to_date:   '2020-11-01', event_selectors: File_Opened   })   // .filter(function(event) {return$event_name === 'File Opened'})      // .groupBy(["$distinct_id"],mixpanel.reducer.null())    .map(function(event){  return {              "id":$distinct_id,    // "distinct_id": event.key[0],       "name":$event_name,    // "time": new Date(event.time).toISOString(),     "Day_only": getYearMonth(new Date(event.time)),     "Enabling Entitlement":["Enabling Entitlement"]     };          })            ; }

1 reply

Userlevel 5
Badge +3


I noticed this post has been sitting for awhile, I’m sorry that you did not get an answer from the community!

In case anyone else is working on a similar JQL, did you end up finding a resolution? I’d love to show QBQ how you were able to resolve this.