Google sheets indirect formula dynamic range building - google-sheets

I have an INDIRECT formula in my google sheet.
Formula: =INDIRECT("B"&J4) --> this works without any issues.
I am however trying to define a range with it.
I am trying to get this result: B5:B --> Number 5 would be dynamically pulled from J4.
I tried entering =INDIRECT("B"&J4):B but that is giving me an error: 'Unknown range name: 'B'.'
If however I enter =INDIRECT("B"&J4):B10 for example, the formula will work and will pull the data correctly but I really need the range to be defined B5:B (five being dynamically pulled as described above).
I am hoping to use the here described indirect formula in COUNTIFS formula in order to dynamically define COUNTIFS range, for reference:
=IF(MONTH(B4:B)=8,COUNTIFS(B4:B,">="&B4, B4:B,"<="&EOMONTH(B4,0)),)
=IF(MONTH(B4:B)=8,COUNTIFS(INDIRECT("B"&J4):B,">="&B4, B4:B,"<="&EOMONTH(B4,0)),)
but it is not working. Not sure if this a syntax error of if INDIRECT cannot be used to define a range.

You can include the whole range as text inside the INDIRECT Function.
=INDIRECT("B"&J4&":B")

Related

Google Sheets LOOKUP Function returning the wrong values?

I'm creating a crypto tracking spreadsheet and I'm getting some strange results using the LOOKUP function.
I have two named ranges:
The symbol range is called USDCoinSymbols
and the coin name range is called USDCoinNames
Here are some function results when I try using the LOOKUP function:
Apologies for the mixed casing on the search term. I was experimenting, but
it seems the LOOKUP function isn't case sensitive (for example, BNB returned the correct coin name).
I also tried the inverse, looking up a coin symbol with a coin name (2nd result) and that works fine.
I spent a good couple hours trying to figure this out.
Am I missing something or is this a bug?
Edit: Here is a link to sample spreadsheet and I'm using the CoinGecko API to get this data.
I'm trying to pull the coin name using the symbol to fill up a table I'm creating.
This is not a bug. It's just how LOOKUP works.
LOOKUP requires that all search-column information be in strict least-to-greatest order, so it wouldn't work with your data.
I've added a new sheet ("Erik Help") which is a duplicate of your first sheet. In my sheet, I deleted your LOOKUP formulas from B20:B27 and replaced them with one array formula. This formula uses VLOOKUP with FALSE as the final parameter, meaning that your data is NOT ordered in strict least-to-greatest order and that exact matches should be searched anywhere instead. This one formula fills all results for B20:B:
=ArrayFormula(IF(A20:A="",,IFERROR(VLOOKUP(A20:A,B2:C14,2,FALSE))))
If you are going to be applying this to a larger list elsewhere and want to use your named ranges, just replace B2:C14 with {USDCoinSymbols, USDCoinNames}.
References:
LOOKUP
VLOOKUP
You will need to use the VLOOKUP function instead
=INDEX(IFERROR(VLOOKUP(A20:A25, {USDCoinSymbols, USDCoinNames},2,0)))
This single formula is all you need.
Since your lists are NOT sorted you should use 0 in the function
(please -as always- adjust formula according to your ranges and locale)

Sumifs with or conditional in Google Sheets

I have a database and I need to create a sumifs expression in Google sheets with the following rules: I have a range of cells and this would be a filter for what the sumifs must sum (similar to an OR). I think the image will explain a little bit better what my expected result is:
I have been trying with a lot of examples but none of them have given me the right result.
You can filter the values and then sum up:
First one would be: =SUM(FILTER($B$1:$B$6;$A$1:$A$6=$F$4:$F$6))
Second one: =SUM(FILTER($B$1:$B$6;$A$1:$A$6=$I$4:$I$5))
You can see an example I uploaded to GDrive

ARRAYFORMULA && Extract Num From String

Trying to use an arrayformula on google sheets to auto-populate a column which will extract the number from a string. I've found / made multiple methods of extracting the number from the string, but I can't seem to get it to work in an arrayformula.
This formula works perfectly to extract the text, but because it's creating an array it's not working within the array formula.
TEXTJOIN("",TRUE,IFERROR((MID(H13,ROW(INDIRECT("1:"&LEN(H13))),1)*1),""))
This below just won't work. I've tried multiple methods, but can't get it working. Clearly I'm making a circular reference, but I can't see to solve it.
=ARRAYFORMULA(IF(ROW(C12:C)=12, "Num", IF(ISBLANK(C12:C), "", TEXTJOIN("",TRUE,IFERROR((MID(H13:H,ROW(INDIRECT("1:"&LEN(H13:H))),1)*1),"")))))
Included is an example worksheet, with a column with expected output.
Thanks for your time! :)
Example Worksheet
What you could try, as I demonstrated in M13 on your sheet, is to use REGEXREPLACE() to remove anything from your data that is not a digit through "\D":
=INDEX(IF(H13:H="","",REGEXREPLACE(TEXT(H13:H,"#"),"\D","")))

How to show duplicates on 2 google sheets at the same time?

This conditional format command shows duplictes on the Sheet1 perfectly:
Appliy to range A:A
=COUNTIF(A:A,A1)>1
Is it possible make it work with Sheet2 at the same time. I've read that INDIRECT could help but I don't understand how to do that.
I tried this with no luck:
If you want it to check both sheets for duplicates, you can still use almost the same formula, but you have to put the references into an Indirect statement:
=countif(INDIRECT("Sheet1!A:A"),A1)+countif(INDIRECT("Sheet2!A:A"),A1)>1
as mentioned in the documentation

Sum of referenced ranges in google spreadsheets

In Google spreadsheets, how do I find the sum of two ranges referenced from different spreadsheets
I want to use something like
=(IMPORTRANGE("keyofsheet1","A1:A100")+ IMPORTRANGE("keyofsheet2","A1:A100"))
and get the sum
Apparently, the above doesn't work. Any help would be appreciated :).
I have found an answer:
Arrayformula is what I was looking for. It basically applies the formula treating the range as a range, instead of as a single element. I still donot totally understand why this works. would be really happy if someone could explain this
I just used
ARRAYFORMULA((IMPORTRANGE("keyofsheet1","A1:A100")+IMPORTRANGE("keyofsheet2","A1:A100")))
and suddenly everything works as it should.
Shouldn't the + operator be conscious of the input type it is getting and automatically respond by returning the appropriate type? why do I need to explicitly specify that this is an array formula
I ran into a similar issue yesterday. Solution was:
=SUM(IMPORTRANGE("keyofsheet1","SheetName!A1:A100")) + SUM(IMPORTRANGE("keyofsheet2","SheetName!A1:A100"))
No need to use ARRAYFORMULA()
2 important notes.
You will probably see a #REF! error in your cell with a red color in the corner. You'll need to hover over it and allow access to the spreadsheets that you're referencing.
If any of the original data in the spreadsheet ranges you're referencing in A1:A100 contain errors such as
#NULL!
#DIV/0!
#VALUE!
#REF!
#NAME?
#NUM!
#N/A
then your formula must be modified to include SUMIF() as follows
=SUMIF(IMPORTRANGE("keyofsheet1","SheetName!A1:A100"), ">0") + SUMIF(IMPORTRANGE("keyofsheet2","SheetName!A1:A100"), ">0")
This ensures that it's only adding anumbers and not error codes.

Resources