How can I filter zero's from a Google Sheets Query Function across two tabs? - google-sheets

I have data across two tabs (May22 and Jun22).
Both have identical headings (A to E).
I can amalgamate the two tabs using:
=QUERY({May22!A:E;Jun22!A:E},"select * where Col3 is not NULL",1)
Col3 (C) contains the Amounts. A lot of which are 0.
How can I modify my query above to filter the zero's from column C inside the query? This will dramatically reduce the size of my amalgamated data.
Thanks
Tom

Related

Count/sum occurrences of word in cell in column - Google Sheets

I have two columns of text/abbreviations i want to summarize in a (or two respectively) tables.
Example:
Column 1: SiteScopeInput
Swap_G09+Remove_U21+Rollout_L07+Swap_L08+Swap_L18+Rollout_L21+Rollout_N35
Remove_U21+Rollout_L07+Swap_L08+Swap_L18+Rollout_L21+Rollout_N35
Swap_G09+Rollout_L07+Swap_L08+Swap_L09+Swap_L18+Rollout_L21+Swap_L26+Rollout_N35
Swap_G09+Remove_U21+Rollout_L07+Swap_L08+Swap_L18+Rollout_L21+Rollout_N35
Here I'd like to summarize how many times words occure - for example:
Swap_G09
Remove_U1
Rollout_L07
and so on.
I've tried a combination of
ArrayFormula, LEN and REGEXREPLACE
but my beginner mind can't wrap around this task.
Any tips? Thanks!
If you want to treat Swap_G09 etc. as a separate word, then a combination of split, flatten and query should do it:
=ArrayFormula(query(FLATTEN(split(filter(A:A,A:A<>""),"+")),"select Col1,count(Col1) where Col1 is not null group by Col1 label Col1 'Word'"))

Joining 2 dynamic ranges using {} operator in Google Sheets

I have 2 tables resulting from the query formulas
formula1
=query(BuchungSystem!A2:AZ,"Select C, F, H, I, J, K, L where Q = "& $B$10)
formula2
=arrayformula({{"MWST ",""}} & QUERY(query(BuchungSystem!A2:AZ,"Select M, N, L where Q = "& $B$10),"SELECT Col1*100, SUM(Col2) GROUP BY Col1, Col3 LABEL SUM(Col2) '' , Col1*100 ''"))
and the result is shown as below
I need to combine 2 ranges since the number of rows in table1 keeps changing and so in table2. Since both are query formulas, they would not expand if the underlying cells have data. To avoid such issues, I am thinking both tables can be joined together with 2 empty lines between tables.
I have tried to join the query result ranges using {formula1;formula2} but it gives me an error since both tables have differing columns. How can I merge the tables one below other?
Mind sharing an example sheet? Here is a quick example of how to include empty columns to make the ranges equal in column size.
={{QUERY(G1:K4,"SELECT G,H,I,J,K")};{"","","","",SUM(QUERY(G1:K4,"SELECT G,H,I,J,K"))}}
If you use 6 columns in one range and only 2 in the next, then you need 4 empty columns in the second {} so their sizes remain the same.

Google Sheets Combine a column with duplicates and update total sum in another colum

This might be something fairly simple but struggling to find a way to do it.
In Column B, I have a list of foods required.
In Column C, I have the amount needed.
In Column D, I have g (for grams) ml (for mills) etc.
I would like to combine the duplicates in Column B and update the totals from Column C, with the g or ml in Column D beside it.
The list I have has been created by using an array formula based on dropdowns in another sheet.
I have seen people using UNIQUE formula in 1 column (this works) and then a SUMIF formula in another column and then a JOIN formula in another... I tried this but the SUMIF is always returning 0.
Would someone please be able to advise on how I can do this?
TIA :D
It's hard to be sure exactly what you need without seeing the data. But based on my understanding of solely what you've posted, this QUERY formula should generate a condensed mini-report:
=QUERY({B2:D},"Select Col1, SUM(Col2), Col3 WHERE Col1 Is Not Null GROUP BY Col1, Col3 LABEL SUM(Col2) ''")
In plain English, this means "Arrange the data from the range B2:D in the same order as the raw data, but sum the second column's data according to matches in both the first and third columns. Only return results for the raw data where the first column is not blank. Replace the default 'sum' header on the second column with nothing; I don't need it."
This formula assumes that every ingredient will always be attached to the same measurement (e.g., 'salt' in Col B is always paired with 'mg' in Col D, etc.). If this is not the case, you will wind up with ingredients being listed as many times as there are different measures in Col D.

Calculate total of values in columns?

I have a Google Sheets document with four sheets. In each sheet, there are two columns: first is a name, and second a value.
I need to get the total of the values from the four sheets in a fifth sheet where the names from the four name-columns correspond.
The column with the values is called differently in most sheets.
How can I accomplish this task?
You can use Query + Arrays, like on image below:
Code:
=QUERY({Sheet1!A2:B;Sheet2!A2:B;Sheet3!A2:B;Sheet4!A2:B};
"select Col1,sum(Col2) where Col1 is not null group by Col1 label Col1 'Name',sum(Col2) 'Total'";0)
Explanation:
First: you combine 4 sheets using an Array. Ranges start from row 2 to omit different columns headers:
{Sheet1!A2:B;Sheet2!A2:B;Sheet3!A2:B;Sheet4!A2:B}
Second: Using Query to perform a total. In Query there are some extra operations:
Col1 is not null - for not showing empty rows in totals
label Col1 'Name',sum(Col2) 'Total' - for naming result columns
Syntax may be a little different depending on your local settings, so look at the working copy:
Link to working copy
Is that serves your needs?

Count borrowed books by type

I am collecting stats for a small library.
I have people completing Google forms when they check out books. I have one field where they enter the call number for each book they borrow. These call numbers fall into three major classifications and take the following form (REF.XX.YYYY, FA.XX.YYYY, AA.XX.YYYY) where X and Y are a combination of letters and numerals.
The result in the spreadsheet would look something like this:
Table
Shared table
I am trying to come up with a way to count the number of instances each classification designation comes up (REF, FA, or AA) throughout the column. For instance, REF should be 3, FA should be 0 and AA should be 1. I made several tries with COUNTIF function but without any success. Any clue about what could be such formula?
The expected output is in red. I want to obtain such output using formulas.
Any help would be appreciated.
You can try getting those classifications using regexextract and then use a query to count everything.
=ArrayFormula(query({A2:A\regexextract(B2:B; "^[A-Z]*")}; "Select Col2, count(Col1) where Col2 <>'' group by Col2 label count(Col1) ''"))
I've added this formula to your table. AA is not showing up in the result because it is not present in the source data.

Resources