Jump to content

Auto Enter Calculation with a IF statement


Recommended Posts

  • Newbies

Hello,

I'm trying to do an auto enter calculation with an IF statement when importing data. I have one field that will either have an IP address or a computer name. If the field is a computer name, i want to strip out some of the text before the actual computer name. The format of the field with a name is (DOMAIN\computer-name), I'm attempting to strip the DOMAIN\ out and just return the computer name. If I do the calculation without the if statement then it works, for the computer name, but removes the IP address.

This is the formula that I have

If ( Position ( Self ; "\" ; 1 ; 1 );
   GetValue(Substitute(TextFormatRemove(Self); "\"; ¶); 2);
   Trim(TextFormatRemove(Self))
)

Basically if the string has a "\" then apply the GetValue… line, otherwise do the Trim Line. The error i'm getting is 

Quote

A number, text constant, field name or “(” is expected here.

Any help would be greatly appreciated.

Link to post
Share on other sites
3 hours ago, maxbehr said:

If I do the calculation without the if statement then it works

Does it really? The expression:

GetValue(Substitute(TextFormatRemove(Self); "\"; ¶); 2)

alone should generate an error, because it contains a text constant that does not end with a quotation mark. That's because the backslash character is an escape character; to include a literal backslash in a text constant, you must escape it itself:

GetValue(Substitute(TextFormatRemove(Self); "\\"; ¶); 2)

and likewise:

Position ( Self ; "\\" ; 1 ; 1 )

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.