Heres what my data look like in Data
| Agent Name | Merchant Name | Committed Funding | Campaign Name Period |
|---|---|---|---|
| adyanti | Digicodes | 7500000 | 11.11 (Oct W4) |
| adyanti | Digicodes | 5000000 | 10.10 (Sep W4) |
| adyanti | ID Cloud Host | 10000000 | 11.11 (Oct W4) |
| adyanti | Karyakarsa | 17500000 | 10.10 (Sep W4) |
| adyanti | Karyakarsa | 14000000 | BAU (Oct W2) |
| adyanti | Karyakarsa | 14000000 | BAU (Oct W3) |
| adyanti | Karyakarsa | 14000000 | SPD&SMS Oct (Oct W4) |
| adyanti | KoinWorks | 60000000 | Tactical (Oct W4) |
| adyanti | Vision+ | 900000 | 10.10 (Sep W4) |
| adyanti | Vision+ | 900000 | SPD&SMS Oct (Oct W4) |
What I expected is something like this in Expectation Result
| Agent Name | Merchant Name | Live Period | Total Budget |
|---|---|---|---|
| adyanti | Digicodes | 11.11 (Oct W4), 10.10 (Sep W4) | 12500000 |
| adyanti | ID Cloud Host | 11.11 (Oct W4) | 10000000 |
| adyanti | Karyakarsa | 10.10 (Sep W4), BAU (Oct W2), BAU (Oct W3), SPD&SMS Oct (Oct W4) | 59500000 |
| adyanti | KoinWorks | Tactical (Oct W4) | 60000000 |
| adyanti | Vision+ | 10.10 (Sep W4), SPD&SMS Oct (Oct W4) | 1800000 |
| Total | 143800000 | ||
| Total All Submission | 2164552000 |
for now, my approach for this is by using Helper reference which Generates a unique Agent name and merchant name using this line function
=Unique(query(Data!$A:$B,"select * where B is not null"))
And join the text of the campaign name /Merchant name/Agent name by using the formula from here.(Credits to @JPV) :
=Query(unique({Data!$B$2:$B, map(Data!$B$2:$B, lambda( item, textjoin(", ", 1, unique(filter(Data!$D$2:$D, Data!$B$2:$B=item)))))}),"Select Col2")
After that, I generate the Total Budget of each merchant and also add the Total Budget of all merchants at the bottom using this line function
={Arrayformula(IF(LEN(INDIRECT("B1:"&"B"&COUNTA($B$2:$B)))=0,,SUMIF(Data!$B$2:$B,$B$2:$B,Data!$C$2:$C)));SUM(INDIRECT("D2:"&"D"&COUNTA($D$2:$D)))}
Using those three line functions above, my data looks like this in Helper
| Agent Name | Merchant Name | Campaign Name Period | Total Budget |
|---|---|---|---|
| adyanti | Digicodes | 11.11 (Oct W4), 10.10 (Sep W4) | 12500000 |
| adyanti | ID Cloud Host | 11.11 (Oct W4) | 10000000 |
| adyanti | Karyakarsa | 10.10 (Sep W4), BAU (Oct W2), BAU (Oct W3), SPD&SMS Oct (Oct W4) | 59500000 |
| adyanti | KoinWorks | Tactical (Oct W4) | 60000000 |
| adyanti | Vision+ | 10.10 (Sep W4), SPD&SMS Oct (Oct W4) | 1800000 |
After preparing the Helper reference I finally using the formula From here.(Credits to @Osm) (Modified by me)
=ArrayFormula({
Helper!A1:D1;
SPLIT(QUERY(FLATTEN(SPLIT(
MAP(QUERY(UNIQUE(Helper!A2:A), "Where Col1 <>'' "),
SUMIF(Helper!A2:A,"="&QUERY(UNIQUE(Helper!A2:A), "Where Col1
<>'' "),Helper!D2:D),
LAMBDA(fw,ct,
TEXTJOIN("♣", 1,
BYROW(FILTER(Helper!A2:D,Helper!A2:A=fw)&"♦",
LAMBDA(c,CONCATENATE(c))))&"♠"&"Total♦"&" ♦"&"
♦"&REPT("♦"&ct,1))), "♣♠")), "where Col1 <> ''"),"♦");
"Total All Submission",
" ",
" ",
SUMIF(Helper!A2:A,"<>",Helper!D2:D)
})
to generate all the data from Helper and and adding total row after each agent name, so my data in Result now looks exactly the same as in the Expectation table above
| Agent Name | Merchant Name | Campaign Name Period | Total Budget |
|---|---|---|---|
| adyanti | Digicodes | 11.11 (Oct W4), 10.10 (Sep W4) | 12500000 |
| adyanti | ID Cloud Host | 11.11 (Oct W4) | 10000000 |
| adyanti | Karyakarsa | 10.10 (Sep W4), BAU (Oct W2), BAU (Oct W3), SPD&SMS Oct (Oct W4) | 59500000 |
| adyanti | KoinWorks | Tactical (Oct W4) | 60000000 |
| adyanti | Vision+ | 10.10 (Sep W4), SPD&SMS Oct (Oct W4) | 1800000 |
| Total | 143800000 | ||
| Total All Submission | 2164552000 |
So the conclusion is, I need something to simplify the process, I'm expecting to have 1 formula line that can generate data directly from Data to be Exactly the same as in Expectation without having to use helper reference.
But for now, I'm going to use this approach until someone is willing to help or maybe until I figure it out myself.
Here's a link to the sample spreadsheet
Thank You!
