CountIFS with filter - google-sheets-formula

Syntax:
CountIfS(Range1, condition1, Range2, Condition2,.... So on)
Can we use FILTER function to retrieve a value.
I am trying below function
=COUNTIFS(A2:A610, "Yes", $B$2:$B$610, FILTER(Sheet2!14:14, Sheet2!2:2=G1))
The output is not correct answer, neither the its throwing any error.
I could save the output of filter(Sheet2!14:14,Sheet2!2:2=G1) in different cell and refer that cell in 2nd condition. But for that I need make plethora cells as I need to use this countifs function in every column.
PS : filter(Sheet2!14:14,Sheet2!2:2=G1) returns the correct value.

that's not how it works. the output of your FILTER formula needs to be exactly 609 cells to match the range of your COUNTIFS formula. only then your formula will work.
in your case try:
=COUNTA(IFNA(FILTER(A2:A; A2:A="yes"; REGEXMATCH(B2:B;
TEXTJOIN("|"; 1; FILTER(Sheet2!14:14; Sheet2!2:2=G1))))))

Related

Array of value from multiple conditions

I wanna return an array of value from multiple conditions.
Currently formula is set to accept one condition.
https://docs.google.com/spreadsheets/d/1pgVlBWYKWtT6AEPyRtZmAYdOXBCjYG_B7pdlvCqYq0A/edit?usp=sharing
The desired result is showed in the ad hoc worksheet
Edit : initial problem solved by player0. Thanks !
Previous post
I'm using curly brace to return an array of value with the IF formula. This works well. I wanted to use IFS function because i wanted to use more conditions.
With a similar table, only the 1st number is returned form the array.
I don't understand why.
https://docs.google.com/spreadsheets/d/1pgVlBWYKWtT6AEPyRtZmAYdOXBCjYG_B7pdlvCqYq0A/edit?usp=sharing
Thanks !
delete range E2:L and use this in E2:
=ARRAYFORMULA(TRANSPOSE(SPLIT(TRANSPOSE(QUERY(
IF((E1:L1=B2:B11)+(E1:L1=C2:C11)+(E1:L1=D2:D11);
"1;2;3;4;5;6;7"; ";");;9^9)); ";"; 1; 0)))

np.where() with np.linspace()

I am trying to find index of an element in x_norm array with np.where() but it doesn' t work well.
Is there a way to find index of element?
x_norm = np.linspace(-10,10,1000)
np.where(x_norm == -0.19019019)
Np.where works with np.arange() and can find the index either first or last element of array creating by linspace.
The numbers generated by np.linspace contains more decimal places than the one you are pasting to np.where (-0.19019019019019012).
So it might be better to use np.argmin to find the nearest value and avoid rounding errors:
x_norm = np.linspace(-10,10,1000)
yournumber=-0.19019019
idx=np.argmin(np.abs(x_norm-yournumber))
You can then go further and add np.where(x_norm==x_norm[idx]) to your code in case if you'll have array with duplicates.
Set the level of precision to 8 using np.round then use np.where to filter data as a mask then apply the mask to the array.
x_norm = np.round(np.asarray(np.linspace(-10,10,1000)),8)
results=x_norm[np.where(x_norm==-9.91991992)]
print(results)

google spreadsheets - filter a cell by it's address

I am using the filter function to find non blank values, the classic:
=FILTER(A2:A99, NOT(ISBLANK(B2:B99)))
To find all the column A headings that have a non-blank value in column B.
But I would also like to always include the last value regardless of it's ISBLANK, something like:
=FILTER(A2:A99, (CELL("address",A2:A99)="$A$99") OR NOT(ISBLANK(B2:B99)))
But this gives me an error, leading me to the strange question of how do I get this to work:
=FILTER(A2:A99, CELL("address",A2:A99)="$A$99")
Or something similar?
As CELL function does not play well in array formulas, you can get addresses as strings for cells like this:
=ARRAYFORMULA(ADDRESS(ROW(A2:A99), COLUMN(A2:A99)))
As for your original problem, you can just add the last cell as the last row:
={FILTER(A2:A98, NOT(ISBLANK(B2:B98))); A99}
Or a dynamic version:
=FILTER(A2:A99, (NOT(ISBLANK(B2:B99))) + (ROW(A2:A99) = (ROWS(A2:A99) + ROW(A2) - 1)))

Use cell text to define vlookup datatable range

In the image above, how do I replace the portion "Tom.A:C" in the vlookup function with the text in cell B2 + .A:C ?
Where "Tom" is the name of a sheet in my workbook and I want to lookup a value in the second column of that sheet.
The formula
=VLOOKUP(lookup,sheet!range,column,match)
Then, in your example, you must write it like this:
=VLOOKUP(A2, TOM ! [Range of the sheet], 2, FALSE)
Edit:
I did not understand the first time exactly what was the question, so here it is the answer:
The formula
=VLOOKUP(lookup,indirect(concat(<cell with sheetname>,<"!"|".">,"<CELL RANGE IN ALL LOOKING SHEETS>")), column, match)
Then in your example:
=VLOOKUP(A2, indirect(concat(A2,".","A:C")), 2, 0)
First you need to concatenate the value of the sheet and range that you want, then with indirect, you take that string value and use it as a valid reference.

How to get an array of values where columns match multiple criteria

I have a table of data similar to:
where I'd like to get just the shapes which match a set of given criteria (in this case week=2 and colour=blue).
I can return the first result using index and match like:
=ArrayFormula(INDEX(C2:C14,MATCH($F$1&$F$2,A2:A14&B2:B14,0)))
but I'd like to return the all matching values (eg square and triangle) in to the range F3:Fsomething. This would preferably be done using a formula that returns a range and isn't "copied-down", as a list of all possible shapes isn't known beforehand.
How can I modify this formula to achieve this?
See if this works:
=FILTER (C2:C14, B2:B14=F2, A2:A14=F1)
to do multiple criteria you want to use * like so
=FILTER (C2:C14, (B2:B14=F2) * (A2:A14=F1))
and if you want the results all in the same cell with a delimiter, use TEXTJOIN
=TEXTJOIN([DELIMETER],[IGNORE EMPTY TEXT],text1)
=TEXTJOIN(", ",TRUE,FILTER(C2:C14,(B2:B14=F2)*(A2:A14=F1)))

Resources