How can I correctly combine these two functions - google-sheets

I am attempting a formula which outputs data from within a range depending on the matching criteria. So for example, if the columns Food category is Taco it then pulls from a list of ID numbers that correspond with a taco. I have a working formula
=IFERROR(INDEX(IMGID!C:C,MATCH(C5,IMGID!A:A,0)))
the issue is it only outputs the first ID from the respective range, so I thought I could include a formula that randomly pulls a cell from within a matching range. This formula
randbetween(1,counta(IMGID!C:C)
I believed I could simply combine the two and replace IMGID!C:C which is where the output or range comes from with
randbetween(1,counta(IMGID!C:C)
for this formula
=IFERROR(INDEX(randbetween(1,counta(IMGID!C:C),MATCH(C5,IMGID!A:A,0)))
but it doesn't work. It only displays an empty cell and I am at a lost
I have tried this formula
=IFERROR(INDEX(randbetween(1,counta(IMGID!C:C),MATCH(C5,IMGID!A:A,0)))
which is a combination of
=IFERROR(INDEX(IMGID!C:C,MATCH(C5,IMGID!A:A,0)))&randbetween(1,counta(IMGID!C:C)
=IFERROR(INDEX(IMGID!C:C,MATCH(C5,IMGID!A:A,0)))*randbetween(1,counta(IMGID!C:C)
There are no error messages only an empty cell where the formula is placed when using
=IFERROR(INDEX(randbetween(1,counta(IMGID!C:C),MATCH(C5,IMGID!A:A,0)))
On the other hand,
=IFERROR(INDEX(IMGID!C:C,MATCH(C5,IMGID!A:A,0)))
works but it only outputs the first option from within that range...I need variation and would like to output randomization of options from the list of possibilities within a range. This is the random formula
randbetween(1,counta(IMGID!C:C)
which works fine and I assumed I could just paste it into the earlier formula

delete B2:C in Missing_Photo sheet and paste this in B2:
=ARRAYFORMULA(IFERROR(VLOOKUP(C2:C, IMGID!A2:C, 3, 0)))
and this in C2:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A, Storefront!B2:C, 2, 0)))

Related

Google sheet Query formula that use text from one column to match another column returning text from adjacent cell

I have a dropdown text column, Claims!B2:B that is supposed to match Ref!A2:A and select Ref!B2:B text.
I tried
=ArrayFormula(IF($B$2:$B="","", LOOKUP($B$2:$B,Ref!$A$2:$A,Ref!$B$2:$B)))
some results not consistent
=QUERY(Ref!A2:B,"Select B where A = "&B2:B&"")
resulting in error
=FILTER(Ref!B2:B,Ref!$A$2:$A=B2:B)
wrong results and not arrayed.
I like to know what should be the simplest array formula for the scenario and if possible correct my other trials for my learning process.
Sample data attached. sample supplier
Please use
for your Category column
=INDEX(IFNA(VLOOKUP(B2:B,Ref!A2:C,3,0)))
and for your GST Stats
=INDEX(IFNA(VLOOKUP(B2:B,Ref!A2:C,2,0)))
(As you notice the only difference is the column number from 2 to 3)
Functions used:
INDEX
IFNA
VLOOKUP

Select the last two names in google sheet

In my data sheet1, I want to use the 'Name in use' column (B) with the last two names with ARRAYFORMULA. 
In my data sheet2, I want column (B) to be repeated with the same code next to the column A get filled 
Please find the sample date sheet below  https://docs.google.com/spreadsheets/d/1_AWRjexJNAcgNGsmrBKU_8JYL03UbAGeiyy4oI8B9fU/edit?usp=sharing 
 Regards,
Nimal PereraSri Lanka
Sheet 1
Your formula seems fine, just the ArrayFormula() needs tweaking. As noted in the docs, ArrayFormula() takes in a range, rather than a single cell.
You would have to do something like this:
=ARRAYFORMULA(IFERROR(UPPER(TRIM(RIGHT(SUBSTITUTE(A2:A5," ",REPT(" ",60)),120)))))
Essentially you type in the range you'd like it to apply on. So at any moment, instead of selecting a single cell for that row, you select the range. If you'd want to apply it to the entire column, use A2:A. You even did it right on sheet2
Sheet 2
Your names seem to be importing correctly once Sheet1 is done right. To have the same code everywhere, use something like this:
=ARRAYFORMULA(IF(LEN(A2:A),"SSD",""))

check for duplicate rows (not just a single cell) in google sheets

Hello I would like to check for duplicate rows, not just a cell, in google sheets, i would like to apply this formula in conditional formatting so it would highlight the cell
Here is a sample of what i want to catch
I would like to catch a duplicate row,group,or pair of cells in exact order. Can anybody help me with the formula?
I tried searching and there seems to be no article about it yet, I also tried using countif on both rows and multiply them, but that does not solve it being a pair.
Let's say you have the following data:
https://ibb.co/sFhjN34
First, range select A1:B1001.
Then, paste the following formula in the custom formula bar.
=AND(A1<>"",COUNTIF(ARRAYFORMULA($A:$A&$B:$B),index(ARRAYFORMULA($A:$A&$B:$B),ROW($A1),))>1)
Explaination:
ARRAYFORMULA($A:$A&$B:$B)
This is creating a virtual array which concat two columns A & B.
E.g. juice crackers -> juicecrackers
index(ARRAYFORMULA($A:$A&$B:$B),ROW($A1),)
Since conditional formating will loop through all rows given the starting range you specify earlier (A1:B1001), this part is trying to loop through ROW($A_) such that index(ARRAYFORMULA($A:$A&$B:$B),ROW($A_),) will return the combined word.
COUNTIF(ARRAYFORMULA($A:$A&$B:$B),index(ARRAYFORMULA($A:$A&$B:$B),ROW($A1),))>1)
Count every combined word that it specified in this array ARRAYFORMULA($A:$A&$B:$B)
If it countup more than 1, it means duplicated.
A1<>"" For those blank cells, we ignore it.
Combine the two conditions. AND(A1<>"",COUNTIF(ARRAYFORMULA($A:$A&$B:$B) ....)
It's not quite as perfect as you'd like, but I think this is a start:
=AND($A1=$A2,$B1=$B2)
This doesn't highlight the last row of any matches it finds, but it might be serviceable for what you want (ex. if Row 1 through Row 3 match, it will only highlight Row 1 and Row 2).
Just change the columns to match the two you're working with, and then if you want it to highlight the entire row, change the Apply to range to A1:Z or however many columns you have.

Split 1st column values to search two other columns and return single value

I'm attempting to take a CONCATENATEd value in a column (A), SPLIT that value in two and VLOOKUP two columns in another sheet (same file). The issue I'm running into is if there are not two values to SPLIT in the CONCATENATEd cells, I get an error. I can flip my formula to search for two values or one (two values JOINed with : or a single value), but not both.
This is the latest iteration of my formula that's only showing half of the desired results.
=ArrayFormula(VLOOKUP(IF(FIND(":",A3:A),SPLIT(A3:A,":"),A3:A),{materialsData!C2:C,materialsData!D2:D,materialsData!E2:H},4,))
Here is an example sheet of what I'm trying to do.
try:
=ARRAYFORMULA(IFNA(VLOOKUP(A3:A, {IF(materialsData!D2:D<>"",
materialsData!C2:C&":"&materialsData!D2:D, materialsData!C2:C), materialsData!F2:F}, 2, 0)))

Troubleshooting formula with array - array arguments are of different size to EQ

In Google Sheets, I have a formula that displays the value of an item in a row if one of its cells contains any of the values listed in a different sheet. It looks like this:
=ARRAYFORMULA(IF(OR(L2 = ZRSKUs!$A$1:$Z$12005), O2, "0"))
If L2 contains any of the values in sheet ZRSKUs, this formula displays the value of the item, which is held in O2. If I drag the formula down it produces the value of every column and I can then get a SUM of this column. I wanted a way to do this without having to drag the formula down every single row (this spreadsheet has about 20,000 rows so it takes a long time to do). I also wanted the formula to add it up too, so it is all done in one cell.
I tried editing the formula to do this, and this is what I came up with:
=ARRAYFORMULA(SUM(IF(OR($L3:$L = ZRSKUs!$A$1:$A$500), $O3:$O, "0")))
However, this gives me an "Array arguments to EQ are of different size" error. I tried adjusting the number of rows in the ZRSKUs sheets so it had the exact same number as my other sheet, but this made no difference.
I'm not sure what's going wrong, so any help or advice would be greatly appreciated!
You get the error because that is not a well-formed array formula, as $L3:$L and ZRSKUs!$A$1:$A$500 are not equal in length. We could rectify this by using another function for the lookup, in this case, MATCH:
=ARRAYFORMULA(SUM(IF(ISNA(MATCH($L$1:$L, ZRSKUs!$A$1:$A$500, 0)), 0, $O$1:$O)))

Resources