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.
Related
Hey Stack Overflow Sheets, I have a question regarding a use case we want to create in our Google Sheet, either with built-in functionality, or with an extension like Sheetgo.
We have 2 sheets with multiple of the same columns (properties) and rows (users). The problem is that only one of the sheets is a trusted source for one column’s data (“source sheet”), and the other sheet has empty or outdated values for the same column (“outdated sheet”), and we need both sheets to have this column match values in rows that have a matching value for another column across both sheets (in our case, an “email” column). After they’re matching, we want to change the formula to sync any changes made for that column between both sheets.
Here’s an obfuscated data example:
Source sheet:
https://docs.google.com/spreadsheets/d/1uxqC3lB15UHhKTzjZyzzVIj5tlPjhCCCZ48xHYEcm0o/edit?usp=sharing
Outdated sheet:
https://docs.google.com/spreadsheets/d/1ckoCh8gMwt2QeBRH1dB2dyFPJUukrjQ-SCgucTL8rhc/edit?usp=sharing
In the example, we’re looking for a formula that would allow us to have a “Type” column value injected into the Outdated Sheet’s Type column, based on both sheet’s matching Email column value. And then, have it so if a row’s “Type” value changes in either doc, the other doc follows.
What formula or extension would I use to go about this? Any help appreciated, thanks!
I tried to create a VLOOKUP and MATCH formula, but I couldn't yet figure out how to have the function first LOOKUP into the Source Sheet, then inject it into the Outdated Sheet based on a matched email column value. Sheetgo made the LOOKUP easier, but I still couldn't figure out how to do an exact operation.
Use importrange() and vlookup(). Put this formula in cell A1 of the target spreadsheet:
=arrayformula(
lambda(
import,
iferror(
vlookup(
C1:C,
{ index(import, 0, 3), index(import, 0, 1) },
2, false
)
)
)(
importrange("1uxqC3lB15UHhKTzjZyzzVIj5tlPjhCCCZ48xHYEcm0o", "Sheet1!A1:F")
)
)
I'd like a formula to be able to calculate a COUNTIF function, but ignoring duplicate values in the same column. My sheet looks something like this:
For example, if I were to count the number of occurrences of "Grass" it would return a result of 4, ignoring the duplicates in columns C and D.
Link to this spreadsheet - https://docs.google.com/spreadsheets/d/110De2u6mKLT7SOTfaXN6EZVqgD35pEeeog9o5WWn5bs/edit?usp=sharing
There is a new sheet on your sample spreadsheet called MK.Idea. There you will find this formula:
=ARRAYFORMULA(COUNTIF(UNIQUE(SPLIT(FLATTEN(Sheet1!B1:G1&"|"&Sheet1!B2:G),"|")),"Grass"))
That uses UNIQUE and a SPLIT(Flatten technique to isolate the "grass" values that are duplicates in a given column
I am turning to you today for help with a problem on Google Sheets.
I receive this data from a Google Sheets form: An answer (0 or 1) to 5 different questions.
I would like to calculate in column A (in green) the scores out of 5 for each row, as soon as a new row is added by the form.
I tried to use the ARRAYFORMULA() function but it does the count for all the cells in the range and not just row by row:
Do you have an idea to have a score out of 5 for each line of question and have it apply to the whole file as soon as a new line is added by the Google Form?
Thanks for your help
If you want to use COUNTIF (English correspondance for NB.SI), modify your formula to:
=ARRAYFORMULA(COUNTIF(IF(B1:F=1,ROW(B1:B)), ROW(B1:B)))
or for your regional settings:
=ARRAYFORMULA(NB.SI(IF(B1:F=1,ROW(B1:B)), ROW(B1:B)))
You can get a row-by-row sum with sumif() like this in cell A3:
=arrayformula( sumif( if(column(B3:F), row(B3:F)), row(B3:F), B3:F) )
This formula uses open-ended range references so it will create results all the way down to the end of the sheet. To limit that, use a range reference like B3:F100 instead.
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)
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&"'" ) )