I have a couple filtering formulas in Google sheet and would like edit them with another variable.
The filter is for example (it shows all non empty cells form a row):
=FILTER('Data Input'!$A$3:$A$9781; NOT(ISBLANK('Data Input'!$X$3:$X$9781)))
The X should be a variable that I can set from a different cell. I was trying stuff like INDEX
=FILTER('Data Input'!$A$3:$A$9781; NOT(ISBLANK('Data Input'!$INDEX(I13)$3:$INDEX(I13)$9781)))
but this just returns an error. Does anyone know how I can pass cell reference variables in a filter function?
It's hard to know for sure, but I believe you're looking for OFFSET rather than INDEX. OFFSET will allow you to enter integers in a cell which you would reference in your filter formula. Those integers would allow you to adjust which column you're using to check for NOT(ISBLANK...) which is what it looks like you're trying to do.
Maybe this will work, I13 will have the value of the column index (Column X = 24)
NOT(ISBLANK(OFFSET($A$1,2,$I$13-1):OFFSET($A$1,9780,$I$13-1))
OFFSET($A$1,2,$I$13-1):OFFSET($A$1,9780,$I$13-1) Should evaluate to $X$3:$X$9781 while I13 = 24
Related
I am trying to generate an arrayformula for the whole column but it does not work, when I use the same formula cell by cell, it generates correct value. Here is the formula for F1 cell:
=if(Iferror(vlookup($D1, INDIRECT("$"&"A"&MATCH(E1,$B:$B,0)+1&":$B"),2,false),"")=E1,"",Iferror(vlookup($D1, INDIRECT("$"&"A"&MATCH(E1,$B:$B,0)+1&":$B"),2,false),""))
I am trying to convert it into ArrayFormula like this and put it in F1:
=ARRAYFORMULA(if(Iferror(vlookup($D:$D, INDIRECT("$"&"A"&MATCH($E:$E,$B:$B,0)+1&":$B"),2,false),"")=$E:$E,"",Iferror(vlookup($D:$D, INDIRECT("$"&"A"&MATCH($E:$E,$B:$B,0)+1&":$B"),2,false),"")))
But this does not work and returns empty column, here is the sheet if you want to test it, you can find formula in column F:
https://docs.google.com/spreadsheets/d/13XLZvvdzK_mqr4Ous50cIEfernw2XrPJWvVgt1hFxtk/edit?usp=sharing
Please share your knowledge how to go about it as I am trying to learn formulas starting from basic level? Thank you.
when working with more than one condition, you can usually use FILTER for it. In this case, I used MAP to refer to both columns D and E, and used FILTER to narrow to the matches in A column, and then to those values that were further than the row of the MATCH of E value. Then, with INDEX I chose the first value of that resulting range.
=MAP(D:D,E:E,LAMBDA(d,e,IFERROR(IF(d="","",INDEX(FILTER(B:B,A:A=d,ROW(B:B)>MATCH(e,B:B,0)),1)))))
Unclear of the full scope but from your expected result scenario(in Column F) you seem to be pulling off second match(if any). well in that case try:
=BYROW(D:D,LAMBDA(dx,IF(dx="",,IFNA(FILTER(ARRAY_CONSTRAIN(FILTER(B:B,A:A=dx),2,1),{0;1})))))
This is fake data for question purpose
sorry for using images rather than markdown table but it would have been very hard to explain if i used markdown table
This is my DATA named Work Sheet where Y and Z is always going to be array and both have corresponding value. EX: for row2:
WBC = 33
this is my stats Sheet where i need to get value of Parameter[x] based on Day & Disease
This is where i took B$151 to B166 and now need value of it from DATA!Z2:Z (Lab values) based on name of parameter,Disease , Day .
where selected cell (B169) has formula:
B166 = RBC
A169 = DAY 1
B1 = Gastroenteritis
=MODE(INDEX(SPLIT(query(DATA!$E$2:$Z, "Select Z where Y contains '"&B$166&"' and E contains '"&$A169&"' and X contains '"&B$1&"' limit 10"),",",1),0,B$167))
Now problem is in DATA sheet user can input item at any index. right now i am using fixed index B$167, but it will break entirely and give wrong results if user changes index of that term. is there any way where i can replace B$167 with dynamic like searching that parameter name in that E,X (Day, Disease). and get index of it and change B$167 with it
i have tried using match search index and pretty everything in my knowledge but problem was Match function only takes single cell and column, so i can't give entire DATA!Y2:Y and split them and then get index. but did not work.
this was the limit of solution i was able to reach.
where A5 = WBC or any in regards
given Y2 becuase was getting error on Y2:Y
=MODE(INDEX(SPLIT(FLATTEN(FILTER(DATA!Z2:Z,DATA!X2:X=B4, DATA!E2:E=C4)),","),0,MATCH(A5,SPLIT(FLATTEN(DATA!Y2),","),)))
but using this will only give index if it is in y2 and also there is no garranty
that parameter is going to be in same index in all cells all the time
i have tried to add 4th condition to Filter on above formula such as search, regexmatch and all but i was not able to solve.
CURRENT SOLUTION: EDIT2
[NEW SHEET][1]
[1]: https://i.stack.imgur.com/rNDh8.png
right now i have did kind of like this and it will be ok if i can combine those 2 (Disease, value) into single cell like this.
RBC: 11
WBC: 33
so i don't need to manually add disease name and Value column each time. i googled but found that i can't skip columns in formula output
so i moved to this.
EDIT2:
i solved this way, now everything is automatic.
where 1 = n
=INDEX(UNIQUE({A2:A}),1)
I have a google sheet which looks like this :
The formula for cell M3 is =COUNTA(UNIQUE(B3:L3)) which outputs the 01/10/00. However the cell B18 is =COUNTA(UNIQUE(B3:B17)) and its output is 15
I wanted to get this count of unique values in the range using the formula but can't figure out the cause of difference of the outputs. Also, the count of unique values in a row should be 11 which is not really reflected in M3 and any changes are not changing the value of the output either.
there is a combo formula for that called COUNTUNIQUE
=COUNTUNIQUE(B3:L3)
The formatting of M3 is probably set to Date and that's converting your number into that date view. Additionally, if you're getting a higher number than you expect in general, double check for trailing spaces that can trick the unique() function.
Here's the straightforward version of my question:
I want to change the following formula to an array formula...
Original formula (from cell J2):
=if(F4="VM:",G4,J1)
My attempt at converting to an array formula (in cell K1):
=arrayformula(if(row(A:A)=1,G3,if(F:F = "VM:",G:G,indirect("K"&row(A:A)-1))))
This works on rows where F = "VM:", but returns a #REF error on other rows. Function INDIRECT parameter 1 value is 'K0'. It is not a valid cell/range reference.
Thoughts on how to fix this?
The more complex version of my question. i.e. Why am I trying to do this?...
I have a weird spreadsheet with data that should really be in a Wiki.
I want to create filter views for each person so they can easily filter on only their own vendors. The original formula will work, but as more vendors are added, I'd like for the formula to automatically work for those rows as well.
If there's a better way to do this, I'm listening.
I don't exactly understand your needs, but If you want to autopopulate your formula, then you only need this code in desire column in row 4 (you can change this to any other - this will autofill down from this point):
=ArrayFormula(if(F4:F="VM:",G4:G,J1:J))
Is this what you are trying to get?
After clarification:
You need this code in J2 only:
=ArrayFormula(VLOOKUP(ROW(J2:J),
QUERY({F:G,ROW(G:G)},"select Col3,Col2 where Col1='VM:'",1)
,2,1)
)
Works for you?
maybe you just need to hide errors?
=IFERROR(ARRAYFORMULA(IF(ROW(A:A)=1,G3,IF(F:F = "VM:",G:G,INDIRECT("K"&ROW(A:A)-1)))),)
I watched a tutorial where the author uses an IF statement along with the ARRAYFORMULA function to add a title row to a column of data. Links are given to the docs; however, for an example of how to use ARRAYFORMULA see this answer.
An example can be seen below:
I was able to populate the C column by placing the following formula in C1:
=ARRAYFORMULA(if(row(A:A) = 1, "spent", B:B - A:A))
I'm confused about the syntax. I understand that X:X references the entire X column but I don't understand how it's being used to check if we're at cell A1 in one context and then being used to apply mass formulas in another context.
How does the above line work?
Can you illustrate with some examples?
It sounds to me that the information you learned led you to expect that row(A:A)=1 translates to row A1?
It works a little different than that, the syntax as your using it now, is basically saying if any row in A:A has a value of 1, then write "spent" else subtract B-A
My suggestion:
use a literal array to make your header, then use the if(arrayformula) to only populate rows with values, for aesthetics:
Example:
={"Spent";arrayformula(if(isnumber(A2:A),B2:B-A2:A,))}
Explanation:
The {} allow you to build a literal array, and using a semicolon instead of a comma allows you to stack your cells vertically, following that we check if there is a value in column A, if so, subtract A from B, else leave it blank.
why not just put the column title directly on the first row cell, and start the array formula from the 2nd row, using the A2:A, B2:B syntax?
If something does not have to be in a formula, better put it directly on the cell - simpler for others to understand what's going on, and the formula will be simpler.
If you put the array formula in line 2, and someone sorts the data, then the arrayformula will move. If it is in the header line, this is less likely to happen.
You can also use the IFS function to achieve a similar effect to the array,
=arrayformula(ifs(row(A1:A)=1,"Spent",A1:A="",,True,B1:B-A1:A)
Here the first condition checks the row number, and if it is row ONE, then inserts a Column Header.
The Second condition - A1:A="",, - ensures that blank lines are ignored.
The Third condition True (ELSE) performs the calculation.
This method also allows for different calculations to performed on different rows depending on requirements.