With IF and IFERROR im gettnig #DIV/0 - google-sheets

im tryig to setup a formula where for example
B2 will always be -1, cos B1 is empty
and lets say
E2 will aways return #DIV/0, cos from target E1 will be populated with some number and F1 will aways be blanck,
explation is simplified, but its about growth %
=if((B1/C1)-1=-1;"-";iferror((B1/C1-1)*SIGN(C1);"-"))
with that formula i manage to get b2 to display "-", but E2 draggig formula to it, displays #DIV/0
but if i use only
=iferror((B1/C1-1)*SIGN(C1);"-")
it manages to get the error and display "-"
what am i missing trying to combine if and iferror in this case? cant spot my mistake

try:
=IFERROR(IF((B1/C1)-1=-1; "-"; (B1/C1-1)*SIGN(C1)); "-")

Related

Using a concatenated string in Google sheets query WHERE condition

I am trying to use the result of a concatenation of a string and cell contents in a query, but the query function does not seem to like it: see this example
https://docs.google.com/spreadsheets/d/1CtPFLhpD3KDHrk-6WoHft4JdMTVa3OcvHHqAidMWwdM/edit?usp=sharing
The strings in cells B2 and B3 appear to be the same, but whilst C3 gives the desired result, C2 does not. B3 simply extracts a string from A3, whereas B2 tags the 'E' on in the formula. The data in the real spreadsheet I am working with is like that in B2, so I have to add the 'E' into the result. The real list of error codes is quite long and varied, so I cannot edit that to just use the number. I also tried using CONCATENATE, but that made no difference.
How do I get the query to recognise the contents of C2 as the string 'E151'?
Most likely there's an trailing space in the result of B2.
See if this helps
=query(A7:B10,"select B where A = '"&trim(B2)&"'",0)
In B2
="E"&mid(A2,30,3)
or
="E"&index(REGEXEXTRACT(A2,REGEXREPLACE(A2,"(\d+)","($1)")),1,5)
(the 5th number in the string)
delete everything in column C and use this in C2:
=INDEX(IFNA(VLOOKUP(TRIM(B2:B4), A7:B11, 2, 0)))
Some great answers to my question, thanks! It was a trailing space causing the problem.
I have combined some of the ideas in the other answers in the real spreadsheet and used
="E" & trim(mid(A2,30,3))
Since some of the error codes are only 2 characters long

Google sheets fill in the gaps using array formula

I have this table and the date column has some blanks if the dates are the same.
i.e. B3:B6 are all 31/01/2022
I want to use column F to fill in the gaps.
I would like to use an arrayformula in cell F2 and it stops when the relative A is empty
i.e. if A279 is empty, F279 is empty too.
I tried to do it using a non-array solution
=IF(B2="",F1,B2)
and I cannot change it to array one
=ArrayFormula(IF(B2:B="",F1,B2:B))
I don't know how to make F1 dynamic and the row number is always one less then B, like showing F2 if B3, F3 if B4
This is the Sheet
Try in F2
=ArrayFormula(lookup(row(A2:A),row(A2:A)/--(B2:B<>""),B2:B))
or (better) in F1
={"Date";ArrayFormula(if(A2:A="",,lookup(row(A2:A),row(A2:A)/--(B2:B<>""),B2:B)))}
to understand how it works, pls fill for instance in I2 =arrayformula(if(A2:A="",,row(A2:A)/--(B2:B<>""))) ... if Bx is blank, we get an error, in that case lookup will take the previous value without error.

Create 3 output results (rows) from one cell (Google Sheets)?

I found an issue, and I do not know if the title explains it precisely, but I somehow need to create 3 different output results (rows) based on the value in one;
I want to only enter one value in cells A2, A3, A4 (maybe have the cells merged?), the same in B2, B3, B4; C2, C3, C4 and D2, D3, D4. But in column E I need 3 output results for one value in B2.
What would be the most efficient way to do that?
Here is the sheet that I am working on:
https://docs.google.com/spreadsheets/d/1PYPjFr3Ny_ycDJ0PEgdd3y7VAW6J32RGtqqPLDIyXQ4/edit?usp=sharing
How can I do that with one formula based on value in B2 I will get 3 output results in column E that will concatenate string "MO_MED_" with B2 and add different endings _EDITABLE, _REQUIRED, _VISIBLE?
Just to make an explicit answer, the correct way to proceed here would be to use the CONCATENATE.

Formula for getting specific rows from other sheets when using IMPORTRANGE()

I'm using IMPORTRANGE() to get values from another sheet. I'm trying to find a formula that I can use for every row without having to type it in individually to get the following result:
For example, in row C3 I want to get the value for G2 from the other sheet. Right now my formula is:
=IMPORTRANGE("16l-7o_K4DMv5QM8KEKA57l_Eqd7nDXEHKHUY7l5jx9Q","G2")
C4 uses "G3", etc. Is there a way to specify that the value will always be "G" + (the current row + 1)? So C3 gets G2, C4 gets G3, etc.?
specify that the value will always be "G" + (the current row + 1)?
=INDIRECT("G"&ROW()+1)
so C3 gets G2, C4 gets G3, etc.
=INDIRECT("G"&ROW()-1)
I'm using IMPORTRANGE() to get values from another sheet
=IMPORTRANGE("16l-7o_K4DMv5QM8KEKA57l_Eqd7nDXEHKHUY7l5jx9Q", "Sheet1!G"&ROW()-1)
Sorry for the hassle - this is what I need:
CONCAT("G", (ROW() - 1)))

How to SET CELL VALUE without written any formula in it

I have values in
A2 = "2"
B2 = "1"
C2 = "3"
and formula in D2
Is it possible to set a value of Cell A3 equals to C2 without putting any formula in A3 and depending upon results of D2 and not using app script?
Like if:
D2 = if(A2>B2,than value A3= C2 eles keep blank
no, it's not possible without formula & without script. the formula would be:
=IF(A2 > B2, C2, )
however, you can add a column to the left of A column and then put this formula in A3 cell:
={"", IF(B2 > C2, D2, )}
For (almost?) all practical purposes "can't be done" but as a curiosity, and perhaps with some liberal interpretation of the requirements (and because tagged google-query-language), it might be considered technically feasible (if largely useless). Assuming the 'trigger' is for the formula in D2 to return 9, in A2 with A3 blank:
=query(C2:D2,"select C where D=9 label C '2'")

Resources