Hi all I have a collection called colResponses with data that looks as follows:
{
name: "Doe, John",
email: "john.doe@mail.com",
officeLocation: "Boston",
date: "5/3/2020",
questionnaire: 1,
flagged: false,
question1: "Question 1",
question2: "Question 2",
question3: "Question 3",
completed: true
},
{
name: "Small, Alice",
email: "alice.small@mail.com",
officeLocation: "Boston",
date: "5/4/2020",
questionnaire: 1,
flagged: false,
question1: "Question 1",
question2: "Question 2",
question3: "Question 3",
completed: true
},
{
name: "Murphy, John",
email: "john.murphy@insight.com",
officeLocation: "Boston",
date: "5/5/2020",
questionnaire: 1,
flagged: false,
question1: "Question 1",
question2: "Question 2",
question3: "Question 3",
completed: true
},
{
name: "Doe, John",
email: "john.doe@mail.com",
officeLocation: "Boston",
date: "5/5/2020",
questionnaire: 2,
flagged: true,
question1: "Question 1",
question2: "Question 2",
question3: "Question 3",
completed: true
},
{
name: "Small, Alice",
email: "alice.small@mail.com",
officeLocation: "Boston",
date: "5/7/2020",
questionnaire: 2,
flagged: false,
question1: "Question 1",
question2: "Question 2",
question3: "Question 3",
completed: true
},
{
name: "Murphy, John",
email: "john.murphy@insight.com",
officeLocation: "Boston",
date: "5/7/2020",
questionnaire: 2,
flagged: true,
question1: "Question 1",
question2: "Question 2",
question3: "Question 3",
completed: true
}
I am trying to achieve what I thought would be some simple aggregation but having some issues.. Ideally i'd like to have one collection grouped by distinct email and use a 'summed' value for the flagged column so it would look like this... Basically if flagged is true in either questionnaire 1 or 2 the flagged column will get set to true.
{
name: "Doe, John",
email: "john.doe@mail.com",
officeLocation: "Boston",
date: "5/3/2020",
questionnaire: 1,
flagged: true,
question1: "Question 1",
question2: "Question 2",
question3: "Question 3",
completed: true
},
{
name: "Small, Alice",
email: "alice.small@mail.com",
officeLocation: "Boston",
date: "5/4/2020",
questionnaire: 1,
flagged: false,
question1: "Question 1",
question2: "Question 2",
question3: "Question 3",
completed: true
},
{
name: "Murphy, John",
email: "john.murphy@insight.com",
officeLocation: "Boston",
date: "5/5/2020",
questionnaire: 1,
flagged: true,
question1: "Question 1",
question2: "Question 2",
question3: "Question 3",
completed: true
},
I have tried a few different approaches but I think this probably makes most sense:
ClearCollect(
colRollup,
Distinct(
colResponses,
email
),
AddColumns(colResponses, "flagged", /* code to sum/aggregate flagged boolean for each distinct email */ )
);
Thanks