Shortening the formula - google-sheets

I can't figure out how to apply ranges for cells in formula, each time I try It doesn't work.
Google Sheet formula: =IF(OR(B2=Items!$A$3;B2=Items!A$4;B2=Items!A$5;B2=Items!A$6;B2=Items!A$7;B2=Items!A$8;B2=Items!A$9;B2=Items!A$10;B2=Items!$A$11);"Melee";IF(OR(B2=Items!A$12;B2=Items!A$13;B2=Items!A$14;B2=Items!A$15;B2=Items!A$16);"Range";"Pick Your Weapon"))
While in Excel this works:
=IF(OR(C1=A1:A3);"Melee";IF(OR(C1=A4:A6);"Range";"Unarmed"))

try:
=INDEX(IF((B2:B=Items!A3)+(B2:B=Items!A4)+(B2:B=Items!A5)+(B2:B=Items!A6)+(B2:B=Items!A7)+(B2:B=Items!A8)+(B2:B=Items!A9)+(B2:B=Items!A10)+(B2:B=Items!A11); "Melee";
IF((B2:B=Items!A12)+(B2:B=Items!A13)+(B2:B=Items!A14)+(B2:B=Items!A15)+(B2:B=Items!A16); "Range"; "Pick Your Weapon")))
or shorter:
=INDEX(IF(REGEXMATCH(B2:B, TEXTJOIN("|"; 1; Items!A3:A11)); "Melee";
IF(REGEXMATCH(B2:B, TEXTJOIN("|", 1; Items!A12:A16)); "Range"; "Pick Your Weapon")))

Related

Formula that fill a sheet if the data from another are being populated based on a criteria

I'm going to be as clear as possible.
First of all I have 2 sheets:
Sheet 1: https://docs.google.com/spreadsheets/d/1AXPQyw_yZUfafjWNW82Rf9E02qR_0c_SYeKOnqQUUdE/edit?usp=sharing
Sheet 2:https://docs.google.com/spreadsheets/d/1v_AyqHXJVhzRNbL-yGoMLxnuKC3z67tZOcQAWwduCN0/edit?usp=sharing
Thank you for your help,
I'm feeling data in Sheet 1 for each week. In the example, I have week 49 and 50.
In Sheet 2, I have a tab for each week. I'd like to have a formula that based on the week number either from the tab name or from the cell A2 in my example, the formula check Sheet 1, look if there is some entries for the week in question and fill automatically the proper tab for the week.
Try this:
=QUERY(IMPORTRANGE("url";"Sheet1A1:E");"select * where Col1 matches '"&A2&"'");
I haven't tested it because the files are shared as Viewand I think that it at least puts you in the right direction.
References
IMPORTRANGE()
QUERY()
try:
=QUERY(REDUCE({""\""\""\""}; SEQUENCE(2; 1; 49); LAMBDA(y; x; {y;
IFERROR(IMPORTRANGE("1v_AyqHXJVhzRNbL-yGoMLxnuKC3z67tZOcQAWwduCN0";
x&"!A3:D100"); {""\""\""\""})})); "where Col1 is not null"; )
see: https://stackoverflow.com/a/74280310/5632629
and: https://stackoverflow.com/a/74483215/5632629

Formula to get next instance of row that contains specific text that works in ARRAYFORMULA

I'm building out a time tracking form and sheet.
I have everything working and I am able to get the next instance of a row that contains that user's name to get the elapsed time they were in that status.
The formula I am currently using is this:
=ArrayFormula(iferror(INDEX($A2:$A,SMALL(IF(B2=$B3:$B,ROW($B$2:$B)),1)), NOW()))
However, this does not work in an ARRAYFORMULA.
I've tried:
=ARRAYFORMULA(VLOOKUP(B2:B, {INDIRECT("B"&ROW(A2:A)+1&":B"), INDIRECT("A"&ROW(A2:A)+1&":A")}, 2, FALSE))
Which doesn't work in array formula because of INDIRECT.
=ARRAYFORMULA(SORTN(FILTER(A3:A, B3:B=B2), 1))
Doesn't work in ARRAYFORMULA
=ARRAYFORMULA(QUERY(A3:C, "SELECT MIN(A) WHERE B = '"&$B2&"' label MIN(A) ''"))
Doesn't work in ARRAYFORMULA.
These formulas all work if I drag them down manually but I don't want to have to open this sheet every couple of hours to drag it down.
Please help!
Link to sheet where I've been messing with formulas:
https://docs.google.com/spreadsheets/d/1ZZOFTFlhmanQPNfRreT2bBinlkb00uaK-qypmEMD3ww/edit
count it:
=ARRAYFORMULA(IF(B2:B="",,IFNA(VLOOKUP(
B2:B&COUNTIFS(B2:B, B2:B, ROW(B2:B), "<="&ROW(B2:B)),
{B2:B&COUNTIFS(B2:B, B2:B, ROW(B2:B), "<="&ROW(B2:B))-1, A2:A}, 2, 0), NOW())))

Textjoin or Concatenate for this case?

hope you have a good day/evening.
Due to I always seems to use importrange function to import multiple sheets. I want to have a quicker way to replace the date (highlighted in red as per the screenshot) with the date referenced in Col A. This is my Google Sheet under the tab name "TextJoin" Google Sheets Link
try:
=INDEX({""; "={"&TEXTJOIN("; ", 1,
"IMPORTRANGE(""13DWtP4L7swqBgK6BGLeA-o_FfyD-D8-Ru30cOPf0I10"", """&
FILTER(TO_TEXT(A2:A)&"!A2:C"")", A2:A<>""))&"}"})
but you may need to wrap it into query and remove empty rows perhaps like:
=INDEX({""; "=QUERY({"&TEXTJOIN("; ", 1,
"IMPORTRANGE(""13DWtP4L7swqBgK6BGLeA-o_FfyD-D8-Ru30cOPf0I10"", """&
FILTER(TO_TEXT(A2:A)&"!A2:C"")", A2:A<>""))&"}, ""where Col1 is not null"", )"})
Try
=importrange("_____","'" & text(A2,"M/d/yy") &"'!A2:C")

Array_Formula + VLookUp not showing a table

I'm trying to extract in Google Sheets the duplicated fruits of the table depending on the date (I want to keep the newest). So I use a VLookUp but I only can extract one column. I've tried putting {} with column numbers between {1;2;3;4} but it doesn't work.
Is there any way to make this with only a formula?
=ARRAYFORMULA(IFERROR(VLOOKUP(UNIQUE(A1:A6);A1:D6;1);""))
try:
=SORTN(SORT(A:D; 4; 1); 9^9; 2; 1; 0)

Google Sheets - Arrayformula referencing other sheets equals broken formula

I have a spreadsheet with a few sheets I reference with =INDEX. The code I use below works fine when I Paste as Formula to all the cells in a column.
=INDEX(DATABASE!A:A, MATCH('SMS FINAL'!C2:C, DATABASE!C:C, 1))
The code I am trying to use has ArrayFormula so that I only have to type the formula in once:
=ArrayFormula(
IF(ROW(E:E)=1,"Company",
IF(ISBLANK(E:E),"",
INDEX(DATABASE!B:B,
MATCH('SMS FINAL'!C:C, DATABASE!C:C, 1)
))))
This breaks the column and only leaves the "Company" in the header row. Any ideas?
try it like this:
=ARRAYFORMULA({"Company";
IF(ISBLANK(E:E), ,
INDEX(DATABASE!B:B,
MATCH('SMS FINAL'!C:C, DATABASE!C:C, 0)))})
or like this:
=ARRAYFORMULA({"Company";
IF(ISBLANK(E2:E), ,
INDEX(DATABASE!B:B,
MATCH('SMS FINAL'!C:C, DATABASE!C:C, 0)))})

Resources