Combine data from multiple tables using indirect references in Google sheets - google-sheets

I am needing to combine all student attendance in one chart. I have tried Query, Vlookup, and Index Match - nothing seems to get the results I want. I need something to search first and last name and return all attendance from all sheets. I would like to use something like CHOOSE and INDIRECT due to the future size of this sheet.
Here is what I have tried:
=ArrayFormula(VLOOKUP(K2&L2,CHOOSE({1,2},{Indirect(E2) & INDIRECT(F2), Indirect(D2)},{1,2})))
=query(Arrayformula({INDIRECT(D2), Vlookup($K$2:$K$45 & $L$2:$L$45, {Indirect(E2) & INDIRECT(F2), Indirect(D2)}, false)}),"select Col1,Col2,Col3,Col10,Col17,Col24,Col31 where not Col1 is null",1
=ArrayFormula((VLOOKUP(K2,INDIRECT($D$3),{1,2,3,10,17,24,31})))
This is a very small example of what the final sheet will be. I included what I want the results to be on a separate tab.
https://docs.google.com/spreadsheets/d/1-XNePmTzVIc84ScasZxh1KlzTBxDyI_glxwg24uXGuI/edit#gid=868379110

Related

google sheets: filter results based on multiple filters, across a row-column search

In Entries Sheet, I have rows with Date, Note, and Number columns
In Reports Sheet, I'd like to show a filtered list of Notes based on the Date and Number columns from Sheet 1.
I've added notes to the example google sheets file
Note that the layout in Entries is a bit odd. Right now, each month has corresponding columns and those are laid out horizontally. I'd expect to have all the dates and their corresponding columns show in a signle set of columns, but I couldn't figure out how to do that. Making that happen is not essential as I think there are pros/cons to changing it. Open to feedback.
Relevant to this issue
I tried various lookup, index, and match methods and did not succeed.
Try this out in B3:
=LAMBDA(notes,IFNA(FILTER(notes,notes<>"")))
(INDEX(TRIM(Entries!A2:ZZZ),,MATCH(B1,Entries!1:1,0)+1))
UPDATE
=IFNA(
QUERY(
BYCOL({1,2},
LAMBDA(
offset,
INDEX(Entries!A2:ZZZ,,MATCH(B1,Entries!1:1,0)+offset))),
"select Col1"&IF(B2="",," where Col2 = "&B2)))

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: Dynamic lookup across two (merged) sheets

I have two external GSheets that are set up as room bookings with a running date in col B and the different rooms ppl can book in col C-AX for Sheet1, C-X for Sheet2, as well as my own Sheet with a list of names (let's call it NameSheet).
Example:
Goal: I want to add an extra column in NameSheet that returns all dates within the next two weeks in which a person has booked a room as well as the room info. Like this:
I used IMPORTRANGE to import both Sheets into my own Sheet (Merged_Sheet) and then merge them dynamically using a simple query formula:
=QUERY({'Sheet1'!A:AX;'Sheet2'!A:AX},"select * where Col1 <>''")
(I had to expand Sheet 2 to AX in order to merge them.)
I then set up another sheet (Date_Filter) to dynamically filter on the next two weeks:
=filter('Merged_Sheet'!A:AX,'Merged_Sheet'!B:B<=today()+7*1)
Finally, I have so far only managed to add a column in my original NameSheet that counts the number of times a there is a partial match on a name in the Merged_Sheet:
=countif(Date_Filter!A:AX,"*"&Name&"*")
Now I'm stuck on how I can return the dates & room info on a partial match (the name columns in the room sheet are "[First Name] [Last Name]" while the employee sheet is set up as "[Last Name],[First Name]") across an entire sheet. I've tried using regexmatch, filter, contains, and even the query function again, but I keep getting function errors.
I would super appreciate any formula help. :)

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

Combining multiple spreadsheets in one using IMPORTRANGE

I would like to aggregate the data of multiple spreadsheets into one spreadsheet.
Spreadsheet 1 has a Row of Strings A2:A500
Spreadsheet 2 has a Row of Strings A2:A500
Spreadsheet 3 is supposed to have a Row of both (Spreadsheet1!A2:A500 AND Spreadsheet2!A2:A500).
Duplicates shall not be handled differently. I would like them to appear as often as they appear in the different sheets.
Is it possible to do this without writing a script or using jQuery, e.g. by using IMPORTRANGE?
What does not work: I have tried using IMPORTRANGE as follows:
ARRAY{IMPORTRANGE("key-of-spreadsheet1","list!A2:A500"), IMPORTRANGE("key-of-spreadsheet2", "list!A2:A500")}
This causes an error.
You should be able to use a vertical array in the Spreadsheet 3:
={IMPORTRANGE("Sheet1Key","SheetName!A2:A500");IMPORTRANGE("Sheet2Key","SheetName!A2:A500")}
Of course, it is also possible to combine several IMPORTRANGE() functions with the QUERY() function, which gives us a greater control over the results we import.
For example, we can use such a construction:
=QUERY(
{
IMPORTRANGE("key-or-url-of-spreadsheet-1", "'sheet-name-1'!A2:Z100");
IMPORTRANGE("key-or-url-of-spreadsheet-2", "'sheet-name-2'!A2:Z100");
IMPORTRANGE("key-or-url-of-spreadsheet-3", "'sheet-name-3'!A2:Z100");
IMPORTRANGE("key-or-url-of-spreadsheet-4", "'sheet-name-4'!A2:Z100")
},
"SELECT * WHERE Col1 IS NOT NULL ORDER BY Col3 ASC"
)
###Explanation:
The above query removes blank lines from imported ranges:
SELECT * WHERE Col1 IS NOT NULL
and sorts ascending all data collected together in relation to the third column:
ORDER BY Col3 ASC
For descending, just use DESC in place of ASC.
Of course, we can also arrange any other criteria, or omit them displaying everything without modification:
"SELECT * "
###Note:
In order to use the above constructed query, we first need to call a single IMPORTRANGE() method for each of the spreadsheets we want to refer:
=IMPORTRANGE("key-or-url-of-spreadsheet-1", "'sheet-name-1'!A2:Z100")
We have to do this even if we refer to the same spreadsheet in which we write this formula, but for every spreadsheet it is enough to do it once.
This is to be able to connect these sheets and allow access to the sheets (to which we have the access rights anyway):
                                                    
After giving permission for all spreadsheets, we can use the above query.
I am also applying above given formula for getting data from multiple spreadsheet which is getting an error something is like IN ARRAY_LITERAL An array literal was missing values for one or more rows.
Easy fix: Apply the filter to the entire column / sheet instead of just the current selection. This will automatically update all of the filters to include new additions.

Resources