Google Sheets equivalent for Excel's AGGREGAT formula - google-sheets

I am using Google Sheets and I need to implement following excel formula into my sheet.
https://docs.google.com/spreadsheets/d/1XzAYEezt2gNt_tdbxyZT-p6XwjNdhvUbt_9rBoABlhI/edit?usp=sharing
=IFERROR(INDEX(Formularantworten!B:B;AGGREGAT(15;6;ROW(Formularantworten!$B$2:$B$100)/(Formularantworten!$B$2:$B$100<>"")/(Formularantworten!$H$2:$H$100<>"");ROW(A1)));"")

Well if you want to match two columns and index a third column, finding the first match, you can do what you used to do in Excel before Aggregate came along:
=index(C:C,match(1,(A:A<>"")*(B:B<>""),0))
or
=index(C:C,min(if((A:A<>"")*(B:B<>""),row(A:A))))
But in Google sheets you have more options and are more likely to use something like
=query(A:C,"select C where A is not null and B is not null limit 1")

Related

Extract all partial matches: AGGREGRATE FORMULA TO replicate in GOOGLE SHEET

I need help on replicating below formula into Google sheet. Since google sheet does not support Aggregate, I am having difficulties replicating it into google sheet.
I need a formula which will list out all partial match item based on specific text from data.
Help is much appreciated.
Below is the formula I am using in excel:
=IFERROR(IF(F5>$D$9,"",INDEX($B$5:$B$16,AGGREGATE(15,6,(ROW($B$5:$B$16)-ROW($B$5)+1)/ISNUMBER(SEARCH($D$5,$B$5:$B$16)),F5)))," ")
and below is sample data and result outcome:
use in F2:
=QUERY(A2:A; "select A where A contains '"&C2&"' limit "&C6; 0)
or case insensitive:
=QUERY(A2:A; "select A where lower(A) contains '"&LOWER(C2)&"' limit "&C6; 0)

Vlookup in same range within different sheets on a different Google Spreadsheet | Google Sheets

I'm hoping to do a VLOOKUP in a different Google Sheet based on 2 criteria: sheet name and then the lookup value. My data looks something like this:
A1 B1 C1
Sheet_Name Lookup_Value Lookup_Value
Sheet_1 123456 =vlookup(B3,"Sheet_1!$A$1:$C$1000",2,false)
Sheet_1 987456 =vlookup(B4,"Sheet_1!$A$1:$C$1000",2,false)
Sheet_2 654123 =vlookup(B5,"Sheet_2!$A$1:$C$1000",2,false)
Sheet_3 959595 =vlookup(B6,"Sheet_3!$A$1:$C$1000",2,false)
Sheet_3 621346 =vlookup(B7,"Sheet_3!$A$1:$C$1000",2,false)
Is there a way I can choose the sheet in my vlookup equation based on the value in column A rather than going in manually and updating this?
Currently, I'm trying this, but it's not working:
=vlookup(B3,importrange("key_here",indirect(A3)&"!A1:C1000"),2,false)
Use INDIRECT:
=vlookup(B3,INDIRECT("'"&A3&"'!$A$1:$C$1000",2,false)
Figured it out: Google doesn't require the indirect function. So what works is:
=vlookup(B3,importrange("key_here",A3&"!A1:C1000"),2,false)

SUMIF across many sheets

I have a Google sheets document where several sheets have the same column layout. I'd like to sum column J if column G = "cat".
Essentially, this:
=SUMIF('A'!G3:G,"=cat", 'A'!J3:J) + SUMIF('B'!G3:G,"=cat", 'B'!J3:J) + SUMIF('C'!G3:G,"=cat", 'C'!J3:J)
But, with lots of sheets, that is cumbersome. How can I reduce that to something like this:
=SUMIF(INDIRECT({A,B,C}&"!G3:G"), "=cat", INDIRECT({A,B,C}&"!J3:J"))
excel has a solution with INDIRECT array-formula, see it here.
Unfortunately INDIRECT doesn't support iteration over an array in google-sheets
Syntax {A,B,C}&"!G3:G is not possible.
Workaround
The first step is to simplify the formula to:
=SUM(FILTER({Sheet1!B:B;Sheet2!B:B},{Sheet1!A:A;Sheet2!A:A} = "Cat"))
The hard part is to manually type all sheet names with ranges. I suggest to make a list of sheet names called Sheets_List:
Sheet1
Sheet2
And then use join to produce the proper formula text:
="{'"&JOIN("'!B:B;'",Sheets_List)&"'!B:B}"
The result is text "{'Sheet1'!B:B;'Sheet2'!B:B}", use it to build the formula.

How to use Sumif using range from a complete different Googlesheet/doc

I know how sumif works when I need to access it within the same Google "workbook" (using the analogy from excel). By workbook I mean a collection of sheets, not sure whether there is a different way to refer to Google workbook.
For example in the sheet (Example 3): https://docs.google.com/spreadsheets/d/1Dm-N-1X38zHartE3JbPUtWDnYwEpkGHl6v06huvjSa8/edit#gid=0
I have Sheet2, with column A contain strings and column B containing numerical value. On sheet 1, I have a sumif function which can be query data stored in Sheet2, and sum the cells which match A1 in Sheet1.
The problem starts happening when I try to refer to ranges in a completely different workbook, which is shown below.
I am trying to do a sumif over 2 ranges from a different "workbook". The data is stored here (Example 2): https://docs.google.com/spreadsheets/d/1P5Inf09fLSRmsGbG7LwlE4V-r7DzqY0SB5tJuMKMZH0/edit#gid=0
The Sumif function is in Cell B1 of the following sheet (Example 1):https://docs.google.com/spreadsheets/d/1AitilELd6w7Dbv9d-mKhBYGTBaO6DdkU29Y5mofX2TI/edit#gid=0.
From my understanding importrange is typically used to refer to ranges in completely different workbooks, as a result I use importrange as the first and last arguments in the sumif function in the Sheet Example 1.
What am I doing wrong? Why is this not working?
Can anybody help?
Thanks a lot
See if this query does what you want:
=SUM(query( QUERY( Importrange("1P5Inf09fLSRmsGbG7LwlE4V-r7DzqY0SB5tJuMKMZH0","Sheet1!A1:B10") ) , "select Col2 where Col1 contains '"&A1&"'" ) )

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