Try this:
function myfunk() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName("Sheet0");
const vs = sh.getRange(3,1,sh.getLastRow() - 2,3).getDisplayValues();
const osh = ss.getSheetByName("Sheet1");
osh.clearContents();
let obj = {pA:[]};
vs.forEach((r,i) => {
if(!obj.hasOwnProperty(r[0])) {
obj[r[0]] = {user:[r[1]],sum:Number(r[2])};
obj.pA.push(r[0]);
} else {
obj[r[0]].user.push(r[1]);
obj[r[0]].user = [...new Set(obj[r[0]].user)];
obj[r[0]].sum += Number(r[2])
}
});
let o = [["Date","sumTotal","unique user count"]];
obj.pA.forEach(p => {
o.push([p,obj[p].user.length,obj[p].sum]);
});
osh.getRange(1,1,o.length,o[0].length).setValues(o);
}
Data:
Date |
User |
Total |
09/09/2022 |
Abc |
100 |
09/09/2022 |
Hola1 |
100 |
09/09/2022 |
boygrey |
100 |
09/09/2022 |
JJ11 |
100 |
09/09/2022 |
King |
100 |
09/09/2022 |
Bite00 |
100 |
09/09/2022 |
Jacob22 |
100 |
09/09/2022 |
Abc |
50 |
09/09/2022 |
Hola1 |
50 |
09/09/2022 |
boygrey |
50 |
09/09/2022 |
JJ11 |
50 |
09/09/2022 |
BB12 |
50 |
09/09/2022 |
toyroom |
50 |
10/09/2022 |
James |
100 |
Output:
Date |
unique user count |
sumTotal |
09/09/2022 |
9 |
1000 |
10/09/2022 |
1 |
100 |