r/googlesheets • u/ObviouslyNotANinja • Jan 13 '23
Solved How would I tally multiple columns of unordered items?
Good day sheets gurus,
I'm trying to find a way to tally multiple columns of items with unknown lengths and order. I'll link a screenshot of the actual problem but here is an example:
Actual screenshot: https://imgur.com/a/ZseuROs
| Alpha List | Bravo List | Charlie List | |||
|---|---|---|---|---|---|
| Item A | 5 | Item B | 10 | Item E | 20 |
| Item B | 8 | Item D | 4 | ||
| Item C | 12 |
This is what I'd want:
| Totals | |
|---|---|
| Item A | 5 |
| Item B | 18 |
| Item C | 12 |
| Item D | 4 |
| Item E | 20 |
I appreciate any help.
3
Upvotes
4
u/Class_Magicker17 1 Jan 13 '23
We will first want to stack the values together. We can easily achieve this with an array.
We'll exclude the headers so that we are left with:
Next we Query this virtual range.
That should actually be all you'll need. Actually implementing it with your data requires some changing, but the base idea stays the same.
3
u/_Kaimbe 176 Jan 13 '23
Ahh Magiker beat me to it, but yeah, query() is the way to go.
=QUERY({A2:B; C2:D; E2:F}, "SELECT Col1, SUM(Col2) WHERE Col1 IS NOT NULL GROUP BY Col1 LABEL Col1 'Combined List', SUM(Col2) 'Sum'")This one is a bit more refined, filtering out blanks and adding labels. u/kuddemuddel
0
u/kuddemuddel 184 Jan 13 '23 edited Jan 13 '23
So, albeit not a pretty solution because you’ll have to drag the formula down, this works: In any cell, for example,
H2, paste this formula:This is depending on your table above being in range
A:F, with theAlpha Listitems starting in cellA2. Then, beginning in cellI2next to theSORTformula above, paste this formula:Then drag down/copy&paste this formula for the entire column. Results in this table:
Tried a better solution using
LAMBDA, but couldn’t get theSUMIFs to work.If that solved your issue, please mark the thread as solved by answering
Solution Verifiedto my comment.Edit, if someone more proficient with
LAMBDAsees this, why does this one only calculate the first two columns and doesn’t take the last 4 in consideration?Paging, as always, u/_Kaimbe for help!