Count if using multiple criteria in Google Sheets - arrays

I am trying to to count the number of cells having values either 1 or mp,1 or 1,mp through B3 to AC3.
Here's what I have tried so far:
=SUM(IF(OR(B3:AC3=1, ISNUMBER(SEARCH("1,mp", B3:AC3)),
ISNUMBER(SEARCH("mp,1", B3:AC3))),1,0))
=SUM(IF(OR(B3:AC3=1, ISNUMBER(IFERROR(SEARCH("1,mp", B3:AC3),0))), 1,
ISNUMBER(IFERROR(SEARCH("mp,1", B3:AC3),0))))
=SUM(IF(OR(B3:AC3=1, B3:AC3="1,mp", B3:AC3="mp,1"), 1, 0))`
=SUM(IF(OR(B3:AC3=1, SEARCH("1,mp",B3:AC3), SEARCH("mp,1",B3:AC3)), 1, 0))
Unfortunately, all of them are are giving me same error: An array value could not be found

You can try summing COUNTIF:
=COUNTIF(B3:AC3,1)+COUNTIF(B3:AC3,"1,mp")=COUNTIF(B3:AC3,"mp,1")
Or filtering and counting values:
=COUNTA (IFNA(FILTER(B3:AC3, REGEXMATCH(TO_TEXT(B3:AC3),"^[1|1,mp|mp,1]$"))))

Related

Spreadsheet Formula read the wrong Value

I run the Vlookup Formula with data like this in he Spreadsheet:
A65 B65 C65 D65 E65 F65 G65
AGR 1 1 Penjualan 12/12/2022 Makanan 15,500
I used formula :
=IFNA(Vlookup(A65,A:D,4,0),"")
should returns the value as "Penjualan" or "" if nothing.
but it returns other value.
your formula is correct unless there is one more AGR in range A1:A64. try:
=IFNA(VLOOKUP(A65, A65:D65, 4, 0))
to see that its working properly

How to convert range text to number format when using QUERY and FILTER

I am using this formula in my example sheet to filter the 5 last columns of data in a chart: =INDEX(QUERY(TRANSPOSE(SORTN(TRANSPOSE(FILTER({B3:U3;B5:U7},B1:U1=A11,B2:U2=A12)),5,0,TRANSPOSE(FILTER(COLUMN(B1:U7),B1:U1=A11,B2:U2=A12)),0))&"","select Col5,Col4,Col3,Col2,Col1",))
This is working great, except for the fact that I am unable to use the filtered values in a graph since all the numbers are being formatted as text, and trying to change this via the menu options changes nothing.
I know I can change dates to a date value if I use something like this on one of the filtered ranges in the formula: TEXT(DATEVALUE(J3:3),"mmm dd"), but have been unable to find an equivalent for numeric values.
Does anyone have any ideas on how I can turn range B5:U7 to numbers?
try:
=INDEX(IFERROR(
QUERY(TRANSPOSE(SORTN(TRANSPOSE(FILTER({B3:U3;B5:U7},B1:U1=A11,B2:U2=A12)),5,0,
TRANSPOSE(FILTER(COLUMN(B1:U7),B1:U1=A11,B2:U2=A12)),0))&"","select Col5,Col4,Col3,Col2,Col1",)*1,
QUERY(TRANSPOSE(SORTN(TRANSPOSE(FILTER({B3:U3;B5:U7},B1:U1=A11,B2:U2=A12)),5,0,
TRANSPOSE(FILTER(COLUMN(B1:U7),B1:U1=A11,B2:U2=A12)),0))&"","select Col5,Col4,Col3,Col2,Col1",)))
=INDEX(IFERROR(
QUERY(TRANSPOSE(SORTN(TRANSPOSE(FILTER({B3:U3;B5:U7},B1:U1=A11,B2:U2=A12)),5,0,
TRANSPOSE(FILTER(COLUMN(B1:U7),B1:U1=A11,B2:U2=A12)),0))&"","select "&
TEXTJOIN(",", 1, "Col"&SORT(SEQUENCE(IF(COUNTIFS(B1:1, A11, B2:2, A12)>=5, 5,
COUNTIFS(B1:1, A11, B2:2, A12))), 1, 0)),)*1,
QUERY(TRANSPOSE(SORTN(TRANSPOSE(FILTER({B3:U3;B5:U7},B1:U1=A11,B2:U2=A12)),5,0,
TRANSPOSE(FILTER(COLUMN(B1:U7),B1:U1=A11,B2:U2=A12)),0))&"","select "&
TEXTJOIN(",", 1, "Col"&SORT(SEQUENCE(IF(COUNTIFS(B1:1, A11, B2:2, A12)>=5, 5,
COUNTIFS(B1:1, A11, B2:2, A12))), 1, 0)),)))

google sheet : How to vlookup by matching value in between max and min?

I have 2 sheets like this :
In that 2nd sheet, i want to lookup the id (S/M/L/XL) by checking if value is in between the Min value and Max value. So the goal is to have something like that 2nd sheet where in 'level' column, i need to put a formula so it will check the value is between what range so then it will retrieve the correct 'id' from 1st sheet.
the rule is if the value is >= minvalue and < max value
How can i do this ?
Thanks
use:
=INDEX(IF(A9:A="",,VLOOKUP(A9:A, {C2:C5, A2:A5}, 2, 1)))
Your first table, has overlapping values, so I suggest you think better about the rules you want to apply.
For example, 1, according your table can match both "S" and "M" , same for 3, which can be "M" or "L".
Once you have resolved that, you can use the QUERY function.
Example:
=QUERY($A$2:$D$5,
"select A,D where C<="&A2&" AND D >="&A2&" ORDER BY D DESC LIMIT 1 ")
Working solution can be found here:
https://docs.google.com/spreadsheets/d/1oLVwQqihT_df2y_ZQnfx7By77HnKSFz0bcbOzMuWqOM/edit?usp=sharing
Rather than have min and max columns, you could just use one column to list incremental values that determine the next size, and use vlookup() with a sort option of true - this avoids overlapping values:
=arrayformula({"level";if(A2:A<>"",VLOOKUP(A2:A,{Source!C:C,Source!A:A},2,1),)})

FILTER formula throws error when combining with SUBSTITUTE Google Formula

I am trying to generalize the FILTER formula
I have, which gives me what I need
=FILTER(iConnectionsHelper!A1:L, iConnectionsHelper!K1:K<>"", iConnectionsHelper!L1:L<>"")
But the last column letter L keeps changing, which then, in turn, changes the column letters K and L
So I have, get the last column header column with data
=left(address(1,counta(iConnectionsHelper!$A1:$AA1),2),find("$",address(1,counta(iConnectionsHelper!$A1:$AA1),2))-1)
Get the Column letter from the Header name:
=SUBSTITUTE(ADDRESS(1,MATCH("From Name",'iConnectionsHelper'!A1:AA1,0),4),1,"") = K
=SUBSTITUTE(ADDRESS(1,MATCH("To Name",'iConnectionsHelper'!A1:AA1,0),4),1,"") = L
But if I try to use these in the Filter formula
=FILTER("iConnectionsHelper!A1:"&left(address(1,counta(iConnectionsHelper!$A1:$AA1),2),find("$",address(1,counta(iConnectionsHelper!$A1:$AA1),2))-1), "iConnectionsHelper!K1:"&SUBSTITUTE(ADDRESS(1,MATCH("matchFrom",iConnectionsHelper!A1:AA1,0),4),1,"")<>"", "iConnectionsHelper!L1:"&SUBSTITUTE(ADDRESS(1,MATCH("matchTo",iConnectionsHelper!A1:AA1,0),4),1,"")<>"")
The output is iConnectionsHelper!A1:L
How to get this to work?
each time you construct the range you need to use INDIRECT. try:
=FILTER(INDIRECT("iConnectionsHelper!A1:"&LEFT(
ADDRESS(1, COUNTA(iConnectionsHelper!$A1:$AA1), 2), FIND("$",
ADDRESS(1, COUNTA(iConnectionsHelper!$A1:$AA1), 2))-1)),
INDIRECT("iConnectionsHelper!K1:"&SUBSTITUTE(
ADDRESS(1, MATCH("matchFrom", iConnectionsHelper!A1:AA1, 0), 4), 1, ))<>"",
INDIRECT("iConnectionsHelper!L1:"&SUBSTITUTE(
ADDRESS(1, MATCH("matchTo", iConnectionsHelper!A1:AA1, 0), 4), 1, ))<>"")

How can I use an array as input for FILTER function in Google Spreadsheet?

So this might be trivial, but it's kinda hard to ask. I'd like to FILTER a range based other FILTER results.
I'll try to explain from inside out (related to image below):
I use filter to find all names for given id (the results are joined in column B). This works fine and returns an array of values. This is the inner FILTER.
I want to use this array of names to find all values for them using another outer FILTER.
In other words: Find maximum value for all names for given id.
Here is what I've figured:
=MAX(FILTER(J:J, CONTAINS???(FILTER(G:G, F:F = A2), I:I)))
^--- imaginary function returning TRUE for every value in I
that is contained in the array
=MAX(FILTER(J:J, I:I = FILTER(G:G, F:F = A2)))
^--- equal does not work here when filter returns more than 1 value
=MAX(FILTER(J:J, REGEXMATCH(JOIN(",", FILTER(G:G, F:F = A2)), I:I)))
^--- this approach WORKS but is ineffective and slow on 10k+ cells
https://docs.google.com/spreadsheets/d/1k5lOUYMLebkmU7X2SLmzWGiDAVR3u3CSAF3dYZ_VnKE
I hope to find better CONTAINS function then the REGEXMATCH/JOIN combo, or to do the task using other approach.
try this in A2 cell (after you delete everything in A2:C range):
=SORTN(SORT({INDIRECT("F2:F"&COUNTA(F2:F)+1),
TRANSPOSE(SUBSTITUTE(TRIM(QUERY(QUERY(QUERY({F2:G},
"select max(Col2) group by Col2 pivot Col1"), "offset 1"),,999^99)), " ", ",")),
VLOOKUP(INDIRECT("G2:G"&COUNTA(F2:F)+1), I2:J, 2, 0)}, 1, 1, 3, 0), 999^99, 2, 1, 1)

Resources