Excel formula for combining two IF - excel

I got this formula in inputted which pulls out the value =IF(LEN(LEFT($A2, SEARCH(".xyz", $A2)-1))<13, "Invalid", "")
However I want to include this part of the formula =IF(LEN(LEFT($A2, SEARCH(".twy", $A2)-1))<13, "Invalid", "")
I tried adding OR after the first IF and combining both but it does not work. Any suggestion?
Below is the sample
ID
Result
asldna.xyz
asd.twy
Invalid
asdjhhh.cyv
Invalid
asdhthen.xyz
asdh.xyz,asdh.cyv
Invalid

Try this:
=IF(LEN(LEFT($A2, SEARCH(".xyz", $A2)-1))<13, "Invalid", IF(LEN(LEFT($A2, SEARCH(".twy", $A2)-1))<13, "Invalid", ""))
Such that if the first if is not true and then the second if is not true the output is "".
Edit based on comment:
=IF(LEN(LEFT($A2, SEARCH(".xyz", $A2)-1))<13, "Invalid_1", IF(LEN(LEFT($A2, SEARCH(".twy", $A2)-1))<13, "Invalid_2", ""))

Related

#Error when exporting to .csv from ssrs when trying to replace a comma with another field

I am trying to replace a comma with another field so you can import the data using a csv. I can do that successfuly by adding .ToString().Replace(","," And ") to the end of the field
EX. Fields!Fieldname.Value.ToString().Replace(","," And ")). This will replace the comma with the word And.
The issue I have encounterd is when the field is blank. It then exports a #Error in the cell. I have tried hiding the cell if it is blank but that works for everything but when it exports to a .csv.
If I cannot get the field to be just blank I would like to have it display 99.
Please help.
I have tried this as well...
=Iif(isNothing(Fields!FieldName.Value),"99",(Fields!FieldName.Value.ToString().Replace(","," And ")))
It still displayed an error
The problem is that you are trying to convert NULL (Nothing) to a string. Both sides of IIF are evaluated so even though you will never see the result, false part is failing when FieldName is null.
TO get round this, we first check if the field is null, then replace that with and emptry string "" and then do the ToString() bit.
try the following...
=IIF(
isNothing(Fields!TestField.Value),
"",
(IIF(IsNothing(Fields!TestField.Value),
"",
Fields!TestField.Value
).ToString().Replace(","," And "))
)

Remove after second whitespace

I want to remove text after second whitespace in a cell
this is for excel
 Eduardo Nunez (R) 2B vs. BAL
 Eduardo Nunez
I expect just first name and last name
So, if there is always an item in brackets then this works:
=TRIM(LEFT(A1,FIND("(",A1,1)-1))
See
Note I tested for multiple spaces at the beginning...
If the value you've provided is in cell A1 ...
=LEFT(TRIM(A1),FIND(" ",TRIM(A1),FIND(" ",TRIM(A1))+1)-1)
Try,
=REPLACE(A2&" ", FIND("|", SUBSTITUTE(A2&" ", " ", "|", 2)), LEN(A2), "")
If the ( is always in that place then this shorter version,
=REPLACE(A2, FIND("(", A2)-1, LEN(A2), "")
Sounds like you might have some space/break issues. Try the below. Contains two helper columns. Should quickly calculate and do what you're looking for, but please let me know if it doesn't.
B2 (Helper 1): =TRIM(SUBSTITUTE(A2,CHAR(160)," "))
C2 (Helper 2): =MID(B2,SEARCH(" ",B2)+1,LEN(B2))
D2 (Result): =LEFT(B2,SEARCH(" ",B2)-1)&" "&LEFT(C2,SEARCH(" ",C2)-1)

COUNTIF returns 0 when expected 1

=IF(COUNTIF(A28:AJ28,"*"&automation&"*")
, "need", "no need")
i expect this formula to return 'need'
but i get 'no need'.
how should I change it?
Encapsulate the text in double quotes:
=IF(COUNTIF(A28:AJ28,"*" & "automation" & "*"), "need", "no need")
You've made your formula unnecessarily complex.
Because automation is outside the string it's not treated as a literal string, and inside the COUNTIF function you're getting a #NAME! error, which the IF function regards as false.
The following does work:
=IF(COUNTIF(A28:AJ28,"*automation*"), "need", "no need")

How do I sum results of two if statements in the same cell?

I'm looking to have the results of two If statements calculated and added in the same cell. I'm getting #VALUE! error.
=IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))+IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
=IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
+
IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
Your both IF functions return an empty string "". Using + operator with strings returns #VALUE!. There are different methods to fix it:
use 0 instead of ""
use SUM instead of + (it ignores strings).
And as #John Bustos mentioned in his comment, you can simplify your formula with
IFERROR(value,value_if_error)
IFERROR description

excel vlookup with if functionc

For example:
F2 = VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0)
I would like to add in the function that if $L$2 can not be found in the sheet2!$A$2:$G$169, then show "invalid".
May i know how should i modified to code in excel? Thanks.
First test what gets returned if $L$2 cannot be found by putting in a value you know is not in the search set. For example if it returns 0 then:
=IF(VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0) = 0, "invalid", VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0))
If it returns an error then try something along the lines of
=IF(ISERROR(VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0)), "invalid", VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0))
or just
=IFERROR(VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0), "invlaid")

Resources