Skip to main content

@Replace function

Hi there,
I'm trying to replace my first numeric to a new numeric, e.g. from 38 to 88.
I try put in @Replace(USERID,"38","88") and it prompted me an 'Invalid parameter'.
Any idea what goes wrong here or there is other @function that I could actually use.
Thanks.
William
 

spiveym Thu, 08/21/2014 - 06:03

My first thought would be as to whether you are actually running this function on a character field? If not can you convert the numeric field to a character and then then run the function?

Steven Luciani Fri, 08/22/2014 - 08:21

assuming USERID is a numeric field and you want the virtual field you are creating to be numeric, your equation would be: (This assumes your userids are 2 digits long. if they are longer, change the second parameter in your @str function)

@val(@replace(@str(USERID,2,0),"38","88"))

 

William Yong Mon, 08/25/2014 - 04:34

In reply to by Steven Luciani

Hi Steven,
Thanks for sharing. However, my userid field still remain as it is and not change to '8'. The userid field consists of 8 digits, so the value I put is  @val(@replace(@str(USERID,8,0),"3","8")). Is the formula correct here?
Thanks in advance.

Steven Luciani Mon, 08/25/2014 - 08:03

Hi William,

Just to clarifiy something, you cannot replace the numbers in your original field. You need to append a new field using the field manipulation feature from the ribbon bar, or right click on your current userid field and choose the first choice insert a new field. As a side note, numeric, or virtual numeric fields are always a length of 8 no matter how large the number is inside the field. In your case, you may have USERID's that contain 2 digits, 4 digits, 8 digits, or 12 digits then in your new field, your formula above will change will change all 3's to 8's no matter what position they fall 1 through 12 in your original field.

Hope that clears it up ofr you.