Home > Software design >  Google Sheets Pivot Table Merge Empty by ID
Google Sheets Pivot Table Merge Empty by ID

Time:05-19

So I know that empty cells are the worst for generating pivot tables however I have a huge csv that is generated like this:

ID QTY ITEM DATE
800170 1 Donut 5/21/2022
800170 1 Bun
800170 1 Cake
800169 1 Sandwich 5/20/2022
800169 1 Cake
800169 2 Donut
800168 1 Donut 5/21/2022
800168 1 Cookie
800168 1 Tea
800167 1 Donut 5/22/2022
800167 1 Tea

and this is the pivot table that gets generated from it.

Pivot Table

I am wondering if there is a way to have the dates "merged" by ID as an ID will always have the same Date?

Desired Output: enter image description here

Here is a link to my test google sheet: enter image description here

Output:

enter image description here

Let me know if you have any issues or questions.

References:

  • enter image description here


    or if you want totals:

    =ARRAYFORMULA({QUERY({A:C, VLOOKUP(ROW(D:D), IF(D:D<>"", {ROW(D:D), D:D}), 2)}, 
     "select Col1,sum(Col2) where Col2>0 group by Col1 pivot Col4"), 
     QUERY({A:B}, "select sum(Col2) where Col2>0 group by Col1 label sum(Col2)'Grand Total'"); 
     {"Grand Total", TRANSPOSE(MMULT(TRANSPOSE(QUERY(QUERY({A:C, 
     VLOOKUP(ROW(D:D), IF(D:D<>"", {ROW(D:D), D:D}), 2)}, 
     "select sum(Col2) where Col2>0 group by Col1 pivot Col4"), "offset 1", )*1),
     SEQUENCE(COUNTUNIQUE(A2:A), 1, 1,  ))), SUM(B:B)}})
    

    enter image description here


    or if you really love pivot table design:

    enter image description here

    demo sheet

  • Related