Exclude Multiple Different Cells When Importing Data - google-sheets

I am trying to filter(query()) some specific columns into a spreadsheet where I do some automatic calculations. However, there are 8 or so specific strings that I don't need and clutter the calculations page. I have a list of these strings that I don't need but I can't seem to EXCLUDE these strings from the filter(query()) without creating a 15 line block of text.
What I've Tried:
=FILTER(QUERY(A:C,"select A,C"),QUERY(A:C,"select A")<>D2,D3,D4,D5)
=FILTER(QUERY(A:C,"select A, C"),QUERY(A:C,"select A")<>{D2,D3,D4,D5}) - I have also tried this one joining the text w/ a "," so that there is one value
=FILTER(QUERY(A:C,"select A, C"),QUERY(A:C,"select A")<>D2) - What is silly is THIS ONE VALUE works, but I cant add multiple values without adding 7 more conditions to the filter which would exclude the values that I need excluded, but I would have to change the formula manually and it would be monstrous when I keep adding strings to remove.
The goal is to be able to be able to add another string to a separate cell and have that be excluded as well.
Here is the google sheet: https://docs.google.com/spreadsheets/d/1u-Po1Oae4MTYU10o_-1Yu0s9Ras9JUn4-SFzTkmMldI/edit?usp=sharing

Suggestion
Perhaps you can try using REGEXMATCH so you could add multiple words to be matched but in the reverse way (via placing the REGEXMATCH in a NOT function) to FILTER your data more efficiently as seen below:
=FILTER(QUERY(Sheet1!A:C,"select A, C"),NOT(REGEXMATCH(Sheet1!A:A,"Value 7|Value 3|Value 10|Value 8")))
Alternatively, you could also reference the range of cells you want to exclude in the REGEXMATCH via JOIN function like:
=FILTER(QUERY(Sheet1!A:C,"select A, C"),NOT(REGEXMATCH(Sheet1!A:A,JOIN("|",D2:D5))))
[UPDATE]
If you're using an IMPORTRANGE in your actual sheet formula, then you would need to structure it like this sample. The REGEXMATCH formula also contains a range:
=FILTER(QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/XXXXXX","Sheet1!A:C"),"select Col1, Col3"),NOT(REGEXMATCH(QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/XXXXXX","Sheet1!A:C"),"select Col1"),"Value 7|Value 3|Value 10|Value 8")))
Demo
Sample Test
The referenced Sheet 1
References
REGEXMATCH
NOT
JOIN

Related

Unnest two columns in google sheet

I have a table like this one here (basically it's data from a google form with multiple choice answers in column A and B and non-muliple choice data in column C) I need a separate row for each multiple choice answer.
Column A
Column B
Email
A,B
XX,YY
1#gmail.com
A,C
FF,DD
2#gmail.com
I tried to un-nest the first column and keep the remaining columns like this
enter image description here
I tried several approaches I found with flatten and split with array formulas but I don't know where to start really.
Any help or hint would be much appreciated!
You can use the split function on the column A and after that, use the index function. Considering the table, you can use:
=index(split(A2,","),1,1)
The split function separate the text using the delimiter indicated, returning an array with 1 line and 2 columns; the index function will return the first line and the first column from this array. To return the second element from the column A, just change to
=index(split(A2,","),1,2)
I think there's no easy solution for this. You're asking for as many combinations of elements as multiple-choice elections have been made. Any function in Google Sheets has its potentials and limitations about how many elements it can express. One very useful formula here is REDUCE. With REDUCE and sequences of elements separated by commas counted with COUNTA, you can stablish this formula:
=QUERY(REDUCE({"Col A","Col B","Email"},SEQUENCE(COUNTA(A2:A)),LAMBDA(z,c,{z;LAMBDA(ax,bx,
REDUCE({"","",""},SEQUENCE(ax),LAMBDA(w,a,
{w;
REDUCE({"","",""},SEQUENCE(bx),LAMBDA(y,b,
{y;INDEX(SPLIT(INDEX(A2:A,c),","),,a),INDEX(SPLIT(INDEX(B2:B,c),","),,b),INDEX(C2:C,c)}
))})))
(COUNTA(SPLIT(INDEX(A2:A,c),",")),COUNTA(SPLIT(INDEX(B2:B,c),",")))})),
"Where Col1 is not null",1)
Since I had to use a "initial value" in every REDUCE, I then used QUERY to filter the empty values:

SUMIFS and ARRAYFORMULA within Google Sheets

I have a google sheet with multiple tabs, one of the tabs is for holding each observation of data while another needs to combine data based on certain criteria. I am trying to use a SUMIFS within and ARRAYFORMULA to get the correct information and it will only pull "0" no matter what I try.
I have set up a test google sheet with some dummy information to show an example of what I need to do in a more complex situation.
https://docs.google.com/spreadsheets/d/1JLyEuVijQ8MvfOKrtbRD_YKmRDnTCxf7qCSw9Ggty_Y/edit#gid=1250575550
In this example, the data tab is the individual observations and the sums tab is where I'm trying to pull combinations. I need column D to sum the totals in column E on the data tab if the Month and Year and Type all match what is on the sums sheet. In this example, cell D3 on the sums tab should equal 11.
you cannot use SUMIFS() in Arrayformula(), along with many other functions, though there is no formal documented list.
In your case you can use a SUMIF() instead by &'ing the condtions together.
I've demoed the concept on a new tab called MK_Help in cell D2:
=ARRAYFORMULA(IF(ROW(A2:A) = ROW(A2), "# TOTAL TYPE", IF(A2:A = "", , SUMIF(data!A:A&data!B:B&data!C:C,A2:A&B2:B&C2:C,data!E:E))))
Note that I made a couple of other small changes to your formula.
Namely, that you should always use a true "empty" instead of double quotes in your IF() mask up front tor return empty when there's no value in A. Double quotes("") is actually not quite empty for many other things in Google sheets.
Also I modified your header conndition from ROW(A2:A)=2 to ROW(A2:A) = ROW(A2). I find that this is a more flexible condition for the header as it allows you to potentially insert/delete rows above the header without breaking things.
It seems QUERY() may be good choice. Try-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A is not null group by A,B,C",1)
If you need specific month then you can add criteria to where clause like-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A =5 group by A,B,C",1)

Create Summary from Two Ranges

I have two ranges: one is a list of headers (Column A), and one is a list of categories (On a separate sheet in column B). Both are generated from other sources, and can be dynamic in length (i.e they cannot be guaranteed to be the same size).
I need to make a summary sheet from these. I want to take the first value of headers, then add all the categories, then the second value of headers, then all the categories, etc. Similar to:
HEADER 1
Role 1
Role 2
Role ...
HEADER 2
Role 1
Role 2
Role ...
And so on.
I've tried various options, and I currently have this:
=ARRAYFORMULA( SPLIT(JOIN("|", A1:A6), "|") & "+" & JOIN("~", UNIQUE(Roles!B3:B)) )
This gets me one row with a column for each header with the entire roles range appended. For instance, column one has:
ON-SITE+Project Management & Creative Design~Production Staff~Video~Audio~
and so on across the sheet.
Ideally, I'd add two more SPLIT functions to separate this to a bunch of columns, then simply transpose into a single column and be done. However, it seems you only get one instance of SPLIT in an ARRAYFORMULA. When I add another SPLIT function:
=ARRAYFORMULA( SPLIT(SPLIT(JOIN("|", $A$1:$A$6), "|") & "+" & JOIN("~", UNIQUE(Roles!$B$4:$B)), "+") )
It simply splits the first column into two, then ignores the rest. If I add a second split to that, I only get the Header. It appears you only get one use of SPLIT inside ARRAYFORMULA, then it breaks down. I've read several things about how JOIN and SPLIT don't seem to play nicely inside ARRAYFORMULA.
Is there something I can add or order into this to make it work as desired? I'm also open to other methods, such as using QUERY or REGEX (those I know very little about REGEX). I attempted to create a literal array using TEXTJOIN and {}, but passing this via INDIRECT never seemed to work. I also need to solve this inside gSheets - no scripting unfortunately.
Editable Sheet Here
try:
=ARRAYFORMULA(TRANSPOSE(SPLIT(QUERY("♦"&TRANSPOSE(UNIQUE(Roles!C1:H1))&"♦"&
TEXTJOIN("♦", 1, UNIQUE(Roles!B2:B)),,99^99), "♦")))

Google Sheets trying to match data from two columns on another tab

I have a formula that works as long as all the data it is trying to match from is in Column A. I need this to also look at the data in column B to see if it matches. I also have another formula that matches two different columns and I also need it to look in both A and B for the data. Both of these are used for conditional formatting. Can anyone help me set these up so it is looking on the Received tab in both columns A and B?
Current formulas that work:
=match($C:$C, indirect("Received!A2:A"),0)
=and(match($I:$I, indirect("Received!A2:A"),0), (match($O:$O, indirect("Received!A2:A"),0)))
What I am trying to do but is not working:
=match($C:$C, indirect("Received!A2:B"),0)
=and(match($I:$I, indirect("Received!A2:B"),0), (match($O:$O, indirect("Received!A2:B"),0)))
Test Doc: https://docs.google.com/spreadsheets/d/1dDrmASkiy4KY8ywVuBLdZzAZtvyTohJBFFWtSte5g8A/edit?usp=sharing
try:
=OR(MATCH($C:$C,INDIRECT("Received!A2:A"),0),MATCH($C:$C,INDIRECT("Received!B2:B"),0))
and:
=OR(AND(MATCH($I:$I,INDIRECT("Received!A2:A"),0),(MATCH($O:$O,INDIRECT("Received!A2:A"),0))),
AND(MATCH($I:$I,INDIRECT("Received!B2:B"),0),(MATCH($O:$O,INDIRECT("Received!B2:B"),0))))

Arrayformula - Adding together a dynamically generated list of ranges

I'm looking for a way to add together a dynamically generated list of ranges using (I'm guessing) an ARRAYFORMULA.
The normal way of attacking this is fine if there is a known list of ranges, the example of the results I want would work using this:
=ARRAYFORMULA( A1:A10 + B1:B10 )
In the case I'm after I want to add together ranges in multiple sheets. I don't want the users to have to manually adjust the array formula every time they add a new sheet to be calculated, and I also want to be able to add some logic to include or remove the particular sheet from the calculation, but for now I'm happy to ignore that and just focus on adding cells together.
My approach to this was to create a column with a list of names, each one matching a sheet in the document, and then using that list to dynamically build the list of ranges to add together, using INDIRECT.
.------------.
| sheet1 | <---- SheetListNamedRange
|------------|
| sheet2 |
`------------'
Here's a quick example
=ARRAYFORMULA( INDIRECT("'" & SheetListNamedRange & "'!D4:75") )
There are lots of failure modes depending on how it's done, but this particular formula only puts in the values of the first sheet and ignores any others, which I guess makes sense.
What I'm after is kind of the equivalent of i++ in a loop found in a normal coding language. Is there some way of making this work?
If I understand you correctly, you'd like to get a list generated based on different ranges across different sheets. If your case is as simple as the one you mention in the beginning of your post, the following would do the job.
={Sheet1!A1:A2; Sheet2!B1:B2}
If you want the sum of all these values, you can use SUM.
=SUM({Sheet1!A1:A2; Sheet2!B1:B2})
Please let me know if this isn't what you were looking for, so I can change the answer accordingly.
you can't refer to array of arrays in INDIRECT. you will need to INDIRECT each sheet which contains array.
=SUMPRODUCT(ARRAYFORMULA(INDIRECT(A1&"!"&"D:D")+
INDIRECT(A2&"!"&"D:D")+
INDIRECT(A3&"!"&"D:D")+
INDIRECT(A4&"!"&"D:D")))
note1: in this case result is 25 as sum of 10 + 15.
10 is sum of sheet1!D:D
and 15 is sum of sheet2!D:D
note2: there is no sheet3 and sheet4 which is equal to 0 in INDIRECT
note3: D:D of the sheet where you have the list of sheets needs to be empty

Resources