I have data in google sheets, looking like this:
A
B
C
D
E
F
G
TP
14656
18885
14317
19312
13303
14311
FN
12216
20107
14066
16323
11180
3478
and I want to implement the following formula:
which would manually look like this:
=(B1/(B1+B2))+(C1/(C1+C2))+...+(G1/(G1/G2))
However, I need this formula to be scalable. I've tried to use ARRAYFORMULA and SERIESSUM but could not manage to actually iterate over the row. Does sheets even support this, and if so, how does sheets implement iterating sums?
You can do the following:
=Sum(ArrayFormula(B1:G1/(B1:G1+B2:G2)))
Update:
If you want the range to be dependent on a manually entered j, use:
=Sum(ArrayFormula(Indirect("R1C2:"&"R1C"&j+1,0)/(Indirect("R1C2:"&"R1C"&j+1,0)+Indirect("R2C2:"&"R2C"&j+1,0))))
This assumes that the table in your post starts in A1 (R1C1).
Related
I have a following formula in my google sheets
=TEXTJOIN(" -- ",TRUE,QUERY('sheetName'!B2:F,"SELECT F WHERE B = '"&$A3&"'"))
The formula is in a different sheet, same workbook though, let's call it "sheetResult". Basically it looks-up values and returns them if there is a match. There are two things I would like to achieve with it further. I need it to be an array so that it applies to all of the rows and I need it to return only the unique values found, I have tried the following but it does not work.
=ARRAYFORMULA(IF(A2:A = "" , , TEXTJOIN(", ",TRUE,UNIQUE(QUERY('sheetName'!B2:F,"SELECT F WHERE B = '"&$A2&"'"))) )) --> not sure what syntax to use
I tried filter but filter just returns all of the info stacked up, need the formula to return the data considering the rows in which the lookup value is held.
EDIT: Added a link to shared file to better describe the question.
I want to make the formula in Y3 on the "Students" sheet apply to all of the cells below it, much like an array formula does.
Example
After further studying your situation I came with a simple fix based on your original formula. I understand that you want to apply the Y3 formula to the whole table, but without altering its behaviour. I assume that the only moving part would be the students ID (Column A). Then you only need to modify your formula to lock the fixed variables with something like:
=TEXTJOIN(" -- ",TRUE,UNIQUE(QUERY('.data'!$B$2:$F,"SELECT F WHERE B = '"&A3&"'")))
After you write that on Y3 you would need to select it and drag it down to fill the table. Please leave a comment if you need further help.
I have an Google sheets file with two sheets. I'm trying to reference one sheet's text based on two cells of criteria using a formula in the other sheet. I have one sheet that looks similar to this -
And another that looks like this -
I would like to put a formula on the second sheet that basically says - look on the first sheet for the values in columns A and B and return me the value in column C. The tricky part is - the values in the second sheet may be inverted or there may be an instance where only one value is present, like in row 1 in the first sheet. Also the formula should only fill in a value if both columns match. All text combinations in both sheets are unique.
Is it possible to do this with text? Thank you for your help!
Try the following
=ArrayFormula((IFERROR(VLOOKUP(R2:R&S2:S,{O2:O&P2:P,Q2:Q},2,0))&
IFERROR(IF((R2:R<>"")*(S2:S<>""),VLOOKUP(R2:R&S2:S,{P2:P&O2:O,Q2:Q},2,0),""))))
(Do adjust locale and ranges according to your needs)
Functions used:
ArrayFormula
IFERROR
IF
VLOOKUP
If you can use two keys concated in the lookup table as a virtual key (i.e. make a key like "CAT|DOG"), then you can use that to look in the secondary table.
If you can't guarantee the sort order of the two keys in the secondary table, you can use the following technique to "sort" the two keys so you can make a single lookup key that's always in one stable order.
Sample Table
A
B
C
D
E
SortedKey
Cat
Dog
TRUE
Cat
Dog
CatDog
Dog
Cat
FALSE
Cat
Dog
CatDog
Formulas
Sample formulas for row #1.
For column C, use formula: =A1<B1
For column D, use formula: =IF(C1=TRUE, A1, B1)
For column E, use formula: =IF(C1=TRUE, B1, A1)
For SortedKey, use formula: =concat(D1, E1)
How to create arrayformula sequence number separated by comma in google spreadsheets
expected results is in column B
A
B
5
1,2,3,4,5
2
1,2
3
1,2,3
How about the following sample formula?
Sample formula:
=JOIN(",",ARRAYFORMULA(ROW(INDIRECT("A1:A"&A1))))
When you use this formula, please put this to a cell "B1" and drag down it.
The flow of this formula is as follows.
Create a1Notation of cells using "A1:A"&A1 using INDIRECT.
Retrieve row numbers from the a1Notation using ROW.
Join the row numbers with , using JOIN.
Result:
Note:
When you want to put all result values using one formula, unfortunately, I couldn't find the formula using the built-in functions. In that case, I would like to propose to a custom function as follows. When you use this, please copy and paste the following script to the script editor of Spreadsheet.
And, please put a formula of =SAMPLE(A1:A) to a cell "B1". By this, the result values are put to the column "B" using the values of column "A".
const SAMPLE = v => v.map(([e]) => e && !isNaN(e) ? [...Array(e)].map((_, i) => i + 1).join(",") : "");
References:
INDIRECT
ROW
JOIN
Custom Functions in Google Sheets
You can use TEXTJOIN() with SEQUENCE() function.
=TEXTJOIN(",",TRUE,SEQUENCE(A1))
You can also use this functions in desktop Excel365
I created a slip format in Google Sheets and I would also print it afterwards.
These slips are numbered from 1 to infinity.
I need help in constructing the formula.
What i created so far:
https://docs.google.com/spreadsheets/d/1MU_kBQgfyqgFuVet3hU6DW_WLuYwYYJ51uU-cB38gsQ/edit?usp=sharing
What i wanted to happen:
When I type the number in cell S1, it would also reflect the corresponding QWS No. in cell T2.
To do this, I was thinking that I should incorporate Vlookup (as what i placed in cell S2) inside the Arrayconstrain formula in column T. However, I don't know if it is possible though.
Answer:
Rather than using VLOOKUP, you can do this by running a QUERY instead.
Forumla:
=ARRAY_CONSTRAIN(QUERY('QWS Tracker'!A3:B, "select B where (A="&S1&") or (A="&S1+1&") or (A="&S1+2&")"),3,1)
Rundown of this Formula:
Query the sheet 'QWS Tracker'!A3:B for:
Values of column B where:
The corresponding cell in row A is either S1, S1 + 1 or S1 + 2
Contstrain the Array to length 3
References:
ARRAY_CONSTRAIN - Docs Editors Help
QUERY - Docs Editors Help
Query Language Reference (Version 0.7) | Charts | Google Developers
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.