Google Sheets Filter + Match? Not sure - google-sheets

I have two tabs in a sheet, that have different ranges. One is preset data, the other is an import from a program we use. I'm trying to figure out a way, if possible, to pull specific data from sheet 1, and match it with values in sheet two, that aren't sorted the same.
Example sheet
https://docs.google.com/spreadsheets/d/1OsSWQ_48VrcTU3pXGeJ_1syluKPVeVRune39UA9I3x4/edit?usp=sharing
I'm trying the formula =sort(filter(Sheet1!B1:B,match(B1:B, Sheet1!B1:B ,0)),2,TRUE), but it's just putting the results in order. If I replace the column # on the sort with 1, it sorts it out of order but it doesn't match column B, like I need it to.
The documents i'm working with are 2000+ rows each, I'd rather not manually do this if at all possible.
Please assist? Either way, thank you for reading.

Try:
=arrayformula(iferror(vlookup(MATCH( B1:B,Sheet1!$B$1:B,0),{(ROW(Sheet1!A1:A)),Sheet1!A1:A},2,0)))
Explanation
step#1 =arrayformula(MATCH( B1:B,Sheet1!$B$1:B,0)) will give the row where each value column B will be found in Sheet1!column B
step #2 =arrayformula({ROW(Sheet1!A1:A),Sheet1!A1:A}) will build a virtual matrix whith in column#1 the row and in column#2 the value of Sheet1!column A
finally: join the two formulas as vlookup(___step#1____,____step#2______)

Related

Creating a recursive Formula in Google Sheets

So here's what I'm trying to do: I have a query formula on Sheet 3 that pulls data from Sheet 2, based on values from Sheet 1. Then I add a header/footer row before/after the data. What I want to do is re-run that formula block for each row in Sheet 1 Column A that has data, but in each instance increase the value of the row by one, and stop when the rows are empty.
Can't just do it with a single query with grouping/ordering, because of the headers/footers.
So far, I've got this (just the first two cycles):
`={
{Sheet1!A3,"","","","","",""};
query(Sheet2!D:S, "select D,F,H,J,N,P,R where J contains '"&Sheet1!A3&"' order by F",0);
{"TOTAL","","","","","",Sheet1!B3};
{"","","","","","",""};
{Sheet1!A4,"","","","","",""};
query(Sheet2!D:S, "select D,F,H,J,N,P,R where J contains '"&Sheet1!A4&"' order by F",0); {"TOTAL","","","","","",Sheet1!B4}
}`
The result is this:
screenshot
It works great, but it'll be super tedious to repeat dozens of times.
This is pushing against the bounds of my formula knowledge, so I need someone to point me in the right direction. Is this handled with some sort of INDEX or VLOOKUP or ARRAY function? Or would it require a script?
Could you try with this REDUCE option and let me know if it returns your desired result?
=REDUCE({"","","","","","",""},SEQUENCE(COUNTA(Sheet1!A3:A)),LAMBDA(a,b,{a;
{INDEX(Sheet1!A3:A,b),"","","","","",""};
query(Sheet2!D:S, "select D,F,H,J,N,P,R where J contains '"&INDEX(Sheet1!A3:A,b)&"' order by F",0);
{"TOTAL","","","","","",INDEX(Sheet1!B3:B,b)}}))
You may change the first argument all those "","","" with the headers from your table. Let me know if it's useful

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)

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))))

Using Google Sheets Query to get Max Date for rows of data

I've been trying to use Google Sheets Query to find the more recent data of a particular name while pulling the rest of the data from the row. And having not luck.
This is a sample of what the Raw Data looks like:
And this is the output that I would like to achieve:
The closest I got to the output that I need is
=QUERY('Raw Data'!A:F,"select max(A), B, C, D, E group by B, C, D, E",1)
But the most important data is in F. When I add in F to 'select' the formula breaks, so I also grouped by F. Then that also pulls in the 4/1/17 data for Mark.
Anyone know whats going on? Or have a better formula for me to work with?
Thanks!
As far as what is going on, I worked with your formula and it picked up the extra date for Mark even before I added column F. As I understand it, if you want the max date per person, you really need =QUERY('Raw Data'!A:F,"select max(A),B group by B",1)
I put that in A1 in the worksheet I was using (not the same as the raw data one). So in its column A and B, I now had the maximum date and the person's name. Next to the first date, I put in column C the following formula, then dragged it down. I was simplifying to do just dates, but I believe it could be adapted to handle times if needed (if the person does multiple times a day and you want only the latest).
="'"&text(A3,"yyyy-mm-dd")&"'".
This gave me the date in single quotes, which I then used in column D, that built up the where clause, with the following formula in the first row,="(A=date "&C3&" and B='"&B3&"')" and the draggable formula =D3&" or "&"(A=date "&C4&" and B='"&B4&"')" in each subsequent row.
In the example with 3 people, the last clause ended up in D5 for me, so my final query was=QUERY('Raw Data'!A:F,"select A,B,C,D,E,F where"&D5,1), and that generated the desired results. My hesitation about this answer is whether it will scale, or whether it will too quickly hit a limit on length of the where clause.

Resources