IF statement interpolation - excel

Could anybody tell me what is wrong with the below formula? I think it is something to do with a comma but not sure. Continuously get an error with this.
=IF(S2="customer”,”551”,IF(S2=“business”,”552”,IF(S2=“both”,”551, 552”, “”)))

It appears that you are somehow using quotes that are not recognized by Excel (if the formula you are using is the exact same as the one you posted).
For example, notice how “” (from your formula) is different than "" (the accepted characters).
As others have stated, this works: =IF(S2="customer","551",IF(S2="business","552",IF(S2="both","551, 552", "")))

If you are in a non-US locale you may need to use semicolons ; instead of commas ,. Try with ; instead of ,
=IF(S2="customer";551;IF(S2="busines2";552;IF(S2="both";"551,552";"")))
This works in my excel table.

Try this...
=IF(S2="customer","551",IF(S2="business","552",IF(S2="both","551, 552", "")))

What kind of error are you getting? I put it in as the below and all 4 returns work correctly. Looks the same as yours to me but here it is to be on the safe side.
=IF(S2="customer","551",IF(S2="business","552",IF(S2="both","551, 552","")))

Related

Sharepoint calculated if statement not working

I've done a lot of googling and no solution I've found works for me.
Under the screenshot I have translated what it says.
=IF(ISBLANK([ToDate]),"",[ToDate]-[DaysToWarn]
This only throws an syntax error. I've tried many different solutions but none of which seems to work.
I even built a replica in my test environment to see if that worked, which it did. I'm out of options and I don't know what I am doing wrong.
The problem, most likely, is due to the parameter separator. The documentation says:
All example formulas in this topic use commas "," as the parameter delimiter character. In some countries, the comma is reserved for use as the decimal mark. In such countries, users creating a calculated field must use semi-colons ";" as the delimiter character.
If I'm correct to assume your localization is Swedish, the decimal separator is ',' (comma), and hence the parameter separator to be used shall be ';' (semicolon).
=IF(ISBLANK([ToDate]); ""; [ToDate]-[DaysToWarn])

remove everything after 4th digit using regular expression ruby

string="A.Brilliant.Young.Mind.2014.720p.BluRay.x264.YIFY"
I have a string like the one above, i am trying to prettify all my file names. I want to remove everything after the 4th digit found in the string so the name looks like this
"A.Brilliant.Young.Mind.2014"
so far using regular expression I can only remove everything before the numbers not after with the code below
string=string[/[^0-9]+/]
this worked for me. Thank you once again and please be more considerate next time
string.match(/[a-zA-Z0-9. ]*\d{4}/)

Doing two string manipulations in puppet

I am running puppet 3.8.6
In a template, I need to truncate the last four characters then remove hyphens from a string parameter. For example "foo-bar.txt" should become "foobar".
val[0..-5] works for truncating the last four characters.
val.gsub('-','') works for removing the hyphen.
But this is a syntax error.
val[0..-5].gsub('-','')
How can I do both?
I agree with the comment on your post... I don't think your example would produce a syntax error. However, though this is a little more verbose, I find splitting to be easier to reason about than removing slices of the string. This ought to work, too:
val.split('.')[0].gsub('-','')
Edit: I somehow missed that this was inside a template. Oops! I've updated as Alex Harvey suggested in the comments.

Combining formulas that include "" using putexcel

I'm trying to save some time generating a lot of reports on Excel with a program from Stata using the putexcel command.
It has worked perfectly. However, I'm encountering a problem when mixing 3 formulas in which one includes quotation marks to denote a space " ".
To be more specific, this is the code I'm using:
putexcel B2=formula("IF((VLOOKUP(A2;HI!$1:$1048576;2;));" ";VLOOKUPA2;HI!$1:$1048576;2;))") using "`archivo'", modify sheet("DEFGGF")
The problem here is that it works in Excel, but instead of the space enclosed in " " I'm getting a 0 since it doesn't read the quotation marks.
I have tried enclosing the "" in several other ways, like
'""`
or
"'"'`"`"
but they don't work.
I would post this as a comment, but I never am able to get the backtick (`) character to display properly in a comment.
I think your code should look like
putexcel B2=formula(`"IF((VLOOKUP(...));" ";VLOOKUP(...))"') using ...
but I admit to not having tested this solution. But the general principles involved are explained in the output of the Stata command help quotes##double.

Excel function to get chars between hyphens

I have a string like:
AB-CD-EF-GH-IK
I wanna get EF between second and third hyphen.
Please help me to figure it out, Thanks
Even shorter is:
=TRIM(MID(SUBSTITUTE(A1,"-",REPT(" ",LEN(A1))),2*LEN(A1),LEN(A1)))
Regards
This will work with varying lengths of strings between the dashes. Doesn't look pretty but works.
=LEFT(REPLACE(REPLACE(A1,1,FIND("-",A1),""),1,FIND("-",REPLACE(A1,1,FIND("-",A1),"")),""),FIND("-",REPLACE(REPLACE(A1,1,FIND("-",A1),""),1,FIND("-",REPLACE(A1,1,FIND("-",A1),"")),""))-1)
Not because this is the right approach, but because shorter than (what was at the time!) the accepted Answer:
=MID(A6,FIND("-",A6,FIND("-",A6)+1)+1,FIND("-",A6,FIND("-",A6,FIND("-",A6)+1)+1)-FIND("-",A6,FIND("-",A6)+1)-1)
A small point in its favour may be that it uses only two common-or-garden functions:
MID to extract the string
FIND to find the index numbers of the relevant characters.

Resources