Excel If statement needs to show blanks while being nested - excel

I am writing a formula to see cells that are blank along with see the cells that have a numeric value such as 0,10,-100 etc.
I have the following code that works but if the cell is blank it shows "0" and I need that to show blank. I should note that I am using offsets to make it easier to duplicate the data into other rows and just use REPLACE to speed up the process.
=IF(B1=DATEVALUE("7/3/2020"),OFFSET('CEDAR RAPIDS'!R4,0,0),
IF(B1=DATEVALUE("7/10/2020"),OFFSET('CEDAR RAPIDS'!R25,0,0),
IF(B1=DATEVALUE("7/17/2020"),OFFSET('CEDAR RAPIDS'!R47,0,0),
IF(B1=DATEVALUE("7/24/2020"),OFFSET('CEDAR RAPIDS'!R69,0,0),
IF(B1=DATEVALUE("7/31/2020"),OFFSET('CEDAR RAPIDS'!R91,0,0),
IF(B1=DATEVALUE("8/7/2020"),OFFSET('CEDAR RAPIDS'!R112,0,0),
IF(B1=DATEVALUE("8/14/2020"),OFFSET('CEDAR RAPIDS'!R133,0,0),
IF(B1=DATEVALUE("8/21/2020"),OFFSET('CEDAR RAPIDS'!R154,0,0),
IF(B1=DATEVALUE("8/28/2020"),OFFSET('CEDAR RAPIDS'!R174,0,0),
IF(B1=DATEVALUE("9/4/2020"),OFFSET('CEDAR RAPIDS'!R195,0,0),
IF(B1=DATEVALUE("9/11/2020"),OFFSET('CEDAR RAPIDS'!R215,0,0),
IF(B1=DATEVALUE("9/18/2020"),OFFSET('CEDAR RAPIDS'!R235,0,0),
IF(B1=DATEVALUE("9/25/2020"),OFFSET('CEDAR RAPIDS'!R255,0,0),
IF(B1=DATEVALUE("10/02/2020"),OFFSET('CEDAR RAPIDS'!R275,0,0),
IF(B1=DATEVALUE("10/9/2020"),OFFSET('CEDAR RAPIDS'!R295,0,0),
IF(B1=DATEVALUE("10/16/2020"),OFFSET('CEDAR RAPIDS'!R314,0,0),
IF(B1=DATEVALUE("10/23/2020"),OFFSET('CEDAR RAPIDS'!R334,0,0),
IF(B1=DATEVALUE("10/30/2020"),OFFSET('CEDAR RAPIDS'!R354,0,0),
IF(B1=DATEVALUE("11/6/2020"),OFFSET('CEDAR RAPIDS'!R374,0,0),
IF(B1=DATEVALUE("11/13/2020"),OFFSET('CEDAR RAPIDS'!R394,0,0),
IF(B1=DATEVALUE("11/20/2020"),OFFSET('CEDAR RAPIDS'!R414,0,0),
IF(B1=DATEVALUE("11/27/2020"),OFFSET('CEDAR RAPIDS'!R434,0,0),
IF(B1=DATEVALUE("12/4/2020"),OFFSET('CEDAR RAPIDS'!R454,0,0),
IF(B1=DATEVALUE("12/11/2020"),OFFSET('CEDAR RAPIDS'!R474,0,0)))))))))))))))))))))))))
I found this code below works correctly but I cannot seem to nest it like the above without errors.
=IF(B1=DATEVALUE("7/3/2020"),IF(ISBLANK('CEDAR RAPIDS'!F4),"",OFFSET('CEDAR RAPIDS'!F4,0,0)))

Format the result of the cells with a custom number format that suppresses zeroes, for example
0;-0;;#
By the way, if you want to check if the result of the OFFSET() is zero, then you need to check the result of the OFFSET(), not the anchor of the OFFSET().
There is bound to be a better formula for this scenario than this nested monster with Offset. Just ask.

Related

How to extract specific text from a sentence in Excel?

I have a database that exports data like this:
How can I get for instance, the Net Rentable Area with the values needed:
E.G.
Net Rentable Area
I tried the TextSplit function but I got a spill.
Please let me know what can be done, thanks!
Also it would be nice to see it working in something such as the Asking Rate, which has a different format.
In cell C2 you can put the following formula:
=1*TEXTSPLIT(TEXTAFTER(A2, B2&" ")," ")
Note: Multiplying by 1 ensures the result will be a number instead of a text.
and here is the output:
If all tokens to find are all words (not interpreted as numbers), then you can use the following without requiring to specify the token to find:
=LET(split, 1*TEXTSPLIT(A2," "), FILTER(split, ISNUMBER(split)))
Under this assumption you can even have the corresponding array version as follow:
=LET(rng, A2:A100, input, FILTER(rng, rng <>""), IFERROR(DROP(REDUCE(0, input,
LAMBDA(acc,text, LET(split, 1*TEXTSPLIT(text," "),
nums, FILTER(split, ISNUMBER(split),""), VSTACK(acc, nums)))),1),"")
)
Note: It uses the trick for creating multiple rows using VSTACK within REDUCE. An idea suggested by #JvdV from this answer. It assumes A1 has the title of the column, if not you can use A:A instead.

Excel customer data validation for chars and numbers

I am trying to validate a combination of char and numbers that looks like this XXXX0000000.
I have tried this formula; =OR((LEFT(B2,3)="XXXX",LEN(B2)=11),AND(LEFT(B2,3)="XXXX",LEN(B2)=11).
The error message I receive is as follows:
excel error message
Title: "Excel customer data validation for chars and numbers"
...I have the feeling it's not just about validating XXXX0000000 but it's about the pattern of characters and numbers. Therefor try:
Formula in B1:
=IF(ISERROR(FILTERXML("<t><s>"&A1&"</s></t>","//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''][string-length()=11][substring(.,5)*0=0]")),"Invalid","Valid")
Where:
//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''] - Check if when we translate the first 4 characters to nothing this also equals empty string;
[string-length()=11] - Check that node is 11 characters long;
[substring(.,5)*0=0] - Check that substring from 5th position onwards equals zero when multiplied by zero.
Note: FILTERXML() is case sensitive and is currently checking for uppercase alpha-chars.
EDIT:
To use this in data-validation; Ditch the IF() since you don't need that in validation and nest the remainder in NOT():
=NOT(ISERROR(FILTERXML("<t><s>"&A1&"</s></t>","//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''][string-length()=11][substring(.,5)*0=0]")))
When you select your range, make sure the validation rule has the topleft cell in the reference.
You have two formulas but no joining of them
IE you have an OR formula
=OR((LEFT(B2,3)="XXXX",LEN(B2)=11)
Which will return a true/false answer
You also have an AND formula
=AND(LEFT(B2,3)="XXXX",LEN(B2)=11)
Which will return a true/false answer
when you work through it you are being given a return of:
=True(or false), true (or false)
That isn't a formula and is causing the error output
I think you want to use an IF statement to join them and get an output as desired:
E.g.
=If(OR(LEFT(B2,3)="XXXX",LEN(B2)=11),AND(LEFT(B2,3)="XXXX",LEN(B2)=11), DO SOEMTHING IF TRUE, DO SOMETHING IF FALSE)
I suggest this:
OR(LEFT(B2,3)="XXX",LEN(B2)=11,AND(LEFT(B2,3)="XXX",LEN(B2)=11))
It corrects the number of characters error and sorts the logic.

Excel - multiple value search across multiple columns or one column with multiple values

I have 7 criteria = TMO-1 through to TMO-7
I have two scenarios to search from.
i have either got a single excel with TMO-6, TMO-201, TMO-67,... etc (some have a lot of values)
or i have split the cell up so the values are all in individual cells such that [TMO-6][TMO-201][TMO-67] etc
I have tried two equations from each. for the first one (the preferred solution) i have tried:
=IF(IFERROR(SEARCH("TMO-1",AB8),0) > 0, "TMO-1",IF(IFERROR(SEARCH("TMO-2",AB8),0) > 0, "TMO-2", "false"))
the problem with that is it finds anything that starts with TMO-1, so will show true if TMO-12 is in the cell.
For option 2 i tried:
=IF(AB9:AR9=TMO-1, TMO-1, IF(AB9:AR9=TMO-2, TMO-2, IF(AB9:AR9=TMO-3, TMO-3,IF(AB9:AR9=TMO-4, TMO-4, IF(AB9:AR9=TMO-5, TMO-5, IF(AB9:AR9=TMO-6, TMO-6, IF(AB9:AR9=TMO-7, TMO-7, "N/A")))))))
and i get the error #spill
any ideas ?
Assuming:
ms365 (Hence the #SPILL error);
The option between concatenated values or seperated (hence AB8 against AB9:AR9);
All numbers are prepended with TMO-;
You are looking for the 1st match in sequence (1-7);
If no match is found, you want to return "Not Found".
First thing that came to mind is to just keep the comma-seperated data in AB8 and use a simple trick to concatenate the delimiters with the sequence:
=ISNUMBER(FIND("-"&SEQUENCE(7)&",",A1&","))
To put that in practice, try:
Formula in B1:
=IFERROR(MATCH("X",IF(ISNUMBER(FIND("-"&SEQUENCE(7)&",",A1&",")),"X"),0),"Not Found")
Other options:
=#IFERROR(SORT(FILTERXML("<t><s>"&SUBSTITUTE(A1,", ","</s><s>")&"</s></t>","//s[substring(.,5)<8]")),"Not Found")
Or, using the insider BETA-functions:
=LET(X,MIN(--DROP(TEXTSPLIT(A1,"-",", "),,1)),IF(X<8,"TMO-"&X,"Not Found"))

COUNTIFS counting double amount of values

I've got the following formula that works correctly
=SUM(COUNTIFS(MachineData!N:N,{"*Arlington*","*RenewNorfolk*"}, MachineData!$X:$X,"Y"))
but now if I try to do the same but with "not arlington or not renewnorforlk" I get the wrong answer (it counts double the amount of values that I want to count)
=SUM(COUNTIFS(MachineData!N:N,{"<>*Arlington*","<>*RenewNorfolk*"}, MachineData!$X:$X,"Y"))
what is happening here?
Your first statement is equivalent to
=COUNTIFS(MachineData!N:N,"*Arlington*", MachineData!$X:$X,"Y") + COUNTIFS(MachineData!N:N,"*RenewNorfolk*", MachineData!$X:$X,"Y")
where the array constant is manually split into it two constituent parts.
If you try this with the second statement
=COUNTIFS(MachineData!N:N,"<>*Arlington*", MachineData!$X:$X,"Y") + COUNTIFS(MachineData!N:N,"<>*RenewNorfolk*", MachineData!$X:$X,"Y")
we can see that anything that isn't either Arlington or RenewNorfolk gets counted by both COUNTIFS statements, which isn't what we want the result to be.
The simplest solution is to use
=COUNTIFS(MachineData!N:N,"<>*Arlington*", MachineData!N:N,"<>*RenewNorfolk*", MachineData!$X:$X,"Y")
which requires all the criteria to be met for a data item to be counted.

Excel AVERAGEIFS looking up ONE of the criteria columns

I have built a large data set and I need to see the average results given many different criteria. I've done this with the AVERAGEIFS function and it works just fine, however the more and more I add its getting really time intensive.
I'm wondering if there is a way to nest a vlookup or index match or anything like that in the AVERAGEIFS that read the criteria column heading and criteria in a cell (or 2 if they need to be separated) to be added to the AVERAGEIFS.
Here is an example of my spreadsheet:
The first 3 sets of criteria I want to stay locked.
I want it to read what the 4th criteria column and criteria should be by referencing the I11 cell. The highlighted portion in the formula bar is the part that I want to reference I11 so it reads it and knows that the 4th criteria is the 'code' column and the criteria is '>7'. I can separate this into 2 separate cells if need be.
I've tried a few combinations of VLOOKUP and INDEX MATCH but cannot get it to work.
Data as Text:
Price,Type,sub cat,Time,code,amount,Result,,
,,,,,,,,
9.95,t2,d,ac,2.18," 22,780,893 ",0.73,,T2 and D and AC
118.94,u2,d,bo,2.78," 172,110,893 ",4.07,,
57.63,t1,u,ac,7.09," 128,419,877 ",-2.16,,code
8.88,t2,d,ac,1.50," 62,634,868 ",12.72,,amount < 100 000 000
11.61,u1,u,ac,2.14," 146,982,736 ",1.07,,price >10
13.46,u3,u,ac,0.93," 17,513,672 ",-13.93,,
31.53,t1,u,ac,0.89," 47,170,877 ",1.39,,
16.34,t3,d,bo,1.07," 1,914,767,076 ",-1.42,,
111.59,u1,d,bo,0.62," 2,283,546,000 ",0.67,,
72.4,u3,d,bo,10.37," 951,541,514 ",1.13,,
34.55,u3,d,bo,0.77," 951,541,514 ",-2.52,,
42.25,t1,d,bo,1.05," 63,748,352 ",8.88,,
17.18,u3,u,ac,2.64," 140,217,257 ",4.35,,
97.66,t1,d,bo,3.45," 1,070,383,954 ",1.33,,
58.49,t2,u,bo,8.64," 151,876,559 ",-0.92,,
64.48,t2,d,ac,2.35," 291,967,334 ",3.03,,
38.4,t1,u,ac,17.05," 83,478,472 ",-4.31,,
20.87,u3,d,ac,28.92," 214,080,937 ",-2.16,,
36.53,t1,d,ac,1.43," 73,438,589 ",-2.07,,
89.16,t3,u,ac,1.41," 26,786,958 ",-1.75,,
15.84,t1,u,bo,2.90," 133,560,818 ",1.76,,
3.2,u3,u,bo,2.95," 215,677,667 ",-1.06,,
25.46,t1,d,bo,3.92," 57,148,431 ",1.89,,
40,t2,d,ac,8.00," 65,274,903 ",0.61,,
27.72,t1,u,ac,2.50," 381,400,886 ",6.46,,
29.07,u3,u,ac,2.32," 52,632,107 ",-0.78,,
173.31,t1,d,ac,3.58," 31,547,380 ",-4.92,,
18.22,u3,d,ac,0.58," 292,669,493 ",4.06,,
9.59,t1,d,bo,3.60," 266,883,020 ",3.16,,
115.22,t2,d,bo,4.51," 132,376,476 ",0.78,,
64.48,u3,d,ac,3.03," 338,360,104 ",-0.95,,
41.74,t1,u,bo,25.65," 245,766,436 ",-3.42,,
5.99,t3,u,bo,2.15," 175,054,713 ",-4.37,,
Use INDEX/MATCH to return the correct column. This will require that you separate the column name and the criteria:
=AVERAGEIFS(G:G,B:B,"T2",C:C,"D",D:D,"AC",INDEX(A:F,0,MATCH(I11,$A$7:$G$7,0)),J11)
An idea:
I10 - "Write down the limitation. (You have to use <,>,=,<> AND the value, for e.g.: <5)"
I11 - The user can use relations and values.
In J11, you can reference to I11 ;) It works for me.

Resources