Spreadsheet Formula read the wrong Value - arrays

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

Related

Count if using multiple criteria in Google Sheets

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]$"))))

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),)})

If blank return 0 else run vlookup

I would like to use the vlookup function to match two criteria values firstly based on the value selected in a dropdown menu (country) and the value in A2(name). If the value in A2 Sheet matches the one of the values in the A column in Sheet2 and the value of the dropdown menu in Sheet1 matches one of the values in Sheet2 Column D (Which is a concatenation of the name and country) I would like to return the corresponding value in Sheet2 ColumnC.
If the value is 0 or blank I would like to return 0.
This is what I have tried
=ARRAYFORMULA(
IF(
ISBLANK(
IFERROR(VLOOKUP(A2&C2,Sheet2!$A$2:$E$61,3,1),"0"))))
Not sure what I might be doing wrong
Here is a sample of my data
Sheet 1:
A B C
name1 (vlookup) [dropdownmenu]
and Sheet 2
A B C
name1 val concatenationofA&B
Here is a test sheet as requested:
https://docs.google.com/spreadsheets/d/1jsFnaGY7N9nXyPs5vR32jG5G838w1SgB2XIad7bEFXg/edit?usp=sharing
try:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A&C2:C, {Sheet2!A2:A&Sheet2!B2:B, Sheet2!C2:C}, 2, 0), 0))
I managed to resolve this using the query function
=QUERY(Sheet2!$A$2:$E$61,"select C where B = """&C12&""" and A = """&A12&""" ")
The only problem is I don't know how to suppress NA values/replace them with the value 0

COUNTA in current row in an array formula (Google Sheets)

I have a Google sheet with fixed number of columns and dynamic rows.
I like to use countA to count fields with a value (non-blank) in the current row.
I found a formula here but don't understand it, neither can get it to work.
ArrayFormula(MMULT( LEN(A1:E)>0 ; TRANSPOSE(SIGN(COLUMN(A1:E1)))))
Sheet gives me error: "Function MMULT parameter 1 expects number values. But 'TRUE' is a boolean and cannot be coerced to a number."
The formula should work if you convert the booleans (true or false) returned by LEN(A1:E)>0 to numbers (1 or 0), as Barry already mentioned. This can be done quite easily by wrapping the output of the LEN()-function in an N-function or by preceding it with '--'. So, assuming your data starts in row 2, see if this works:
=ArrayFormula(MMULT( --(LEN(A2:E)>0) , TRANSPOSE(COLUMN(A2:E2)^0)))
An alternative way would be to use COUNTIF()
=ArrayFormula(COUNTIF(IF(A2:E<>"", row(A2:A),),row(A2:A)))
and probably even a combination should work:
=ArrayFormula(MMULT( --(A2:E<>"") , TRANSPOSE(COLUMN(A2:E1)^0)))
If you also want to include a header row, try:
=ArrayFormula(if(row(A:A)=1, "Header", MMULT( --(LEN(A:E)>0) , TRANSPOSE(COLUMN(A1:E1)^0))))
or
=ArrayFormula(if(row(A:A)=1, "Header", MMULT( --(A:E<>"") , TRANSPOSE(COLUMN(A1:E1)^0))))
or
=ArrayFormula(if(row(A:A)=1, "Header", COUNTIF(IF(not(isblank(A:E)), row(A:A),),row(A:A))))
EDIT: (after new question in comments)
If you want to sum the values, you can do that with MMULT() too:
=ArrayFormula(if(row(A:A)=1, "Header", MMULT(if(A1:E<>"", A1:E,0), transpose(column(A1:E1)^0))))
or using sumif:
=ArrayFormula(if(row(A:A)=1, "Header", sumif(IF(COLUMN(A1:E1),ROW(A1:A)),ROW(A1:A),A1:E)))
NOTE: if you want to limit the output to let's say the last row that has values in col A, try:
=ArrayFormula(if(row(A:A)=1, "Header", IF(LEN(A1:A), MMULT(if(A1:E<>"", A1:E,0), transpose(column(A1:E1)^0)),)))
or, again with sumif()
=ArrayFormula(if(row(A:A)=1, "Header", if(len(A1:A), sumif(IF(COLUMN(A1:E1),ROW(A1:A)),ROW(A1:A),A1:E),)))
That formula seems a little complex for your explanation, can't you just use this formula copied down
=COUNTA(A1:E1)
...but specifically addressing your question, you need to change this part
LEN(A1:E)>0
...so that it returns numbers - try
IF(LEN(A1:E)>0;1;0)

Array formula not working in Excel

I have the following table in Excel (blank spaces are empty):
A B C D
1 1
2 3
3 4
4 -2
5 4
6 9
7 8
8
9
10
I would like to return the minimum of column A from A1 to A1000000, using the QUARTILE function, while excluding all negative values. The reason I want it from A1 to A1000000 and not A1 to A7 is because I want to update the table (adding new rows starting from A8) and have the formula also automatically update. The reason I want the QUARTILE and not MIN function is because I will be extending it to calculate other statistics like 1st and 3rd quartile.
This function works correctly and returns 1 (pressing ctrl+shift+enter):
QUARTILE(IF(A1:A7 > -1, A1:A7), 0)
However, when I tried the following, it returned 0 when it should still return 1 (pressing ctrl+shift+enter):
QUARTILE(IF(A1:A1000000 > -1, A1:A1000000), 0)
I also tried the following and it returned 0 (pressing ctrl+shift+enter):
QUARTILE(IF(AND(NOT(ISBLANK(A1:A1000000)), A1:A1000000 > -1), A1:A1000000), 0)
Anybody have a solution to my problem?
Create a dynamic named range, called for example, rng, defined by =OFFSET($A$1,0,0,COUNT($A1:$A10000),1)
Then modify your array formula to refer to rng, via =QUARTILE(IF(rng >-1,rng), 0)
Actually what you have works. Try doing:
=QUARTILE(IF(A:A > 0,A:A ),0)
The reason you are returning 0 is that a blank cell is considered to be of the value 0 when this formula is ran. For example, erase one of the values in the A1:A7 range and your original formula will return 0. Also, I would run the formula on the entire A column if possible (for readability, etc.)
Or do you need to return a "0" if that number is in the list?

Resources