Search code examples
google-sheetsfiltertransposeflattengoogle-query-language

Google Sheets: FIlter/Query/Other to Omit "0" values from Rows AND Columns


The business use case involves a work unit with about 11 people who produce a mixture of about 30 different widgets over the course of a month (Ex: August 2021). On August 1, 2021: Person 1 may be assigned to produce 20 widgets A's and 15 widget T's and that's it. Their tracker is still calculating all the widgets they were not assigned to that day, so that leads to a lot of zeros (which is necessary for other filters). The assignments shift so those zeros change from rows and columns as well.

Each date has it's own row and each widget type it's own column. I'm trying to produce a summary dataset of non-zero data so the manager can quickly see on August 1, 2021, Person 1 had 20 A's and 15 T's instead of having to look at 20 A's, 0 B's, 0 C's, 0 D's.... 15 T's, O U's.... so on and so forth.

How can I filter/query the original data to filter out rows where all cells are 0 (meaning someone didn't work that day), AND columns where all cells are 0 (meaning the individual didn't produce any of that widget type for the whole month)?

Here is a link to a sample that may describe what I'm trying to do better - I only went out to August 5th and Widget D, but I think the point is still clear: https://docs.google.com/spreadsheets/d/1Fobw0YevCPLIMSqXVvxDFgQOgO7VR92Wz8Eh5luZlWk/edit?usp=sharing


Solution

  • try:

    =FILTER(FILTER(A2:E, LEN(TRIM(QUERY(IFERROR(1/(1/A3:E)),,9^9)))>0), {9; 
      LEN(TRIM(FLATTEN(QUERY(TRANSPOSE(IFERROR(1/(1/B3:E))),,9^9))))}>0)
    

    enter image description here