@Replace function

6 posts / 0 new
Last post
William Yong
Offline
Joined: 06/30/2014 - 00:37
@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
Offline
Joined: 02/07/2014 - 05:52

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?

William Yong
Offline
Joined: 06/30/2014 - 00:37

Hi spiveym,
Thanks for the sharing. It does not help even I converted the numeric to character field.
 

Steven Luciani
Offline
Joined: 07/31/2012 - 13:20

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
Offline
Joined: 06/30/2014 - 00:37

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
Offline
Joined: 07/31/2012 - 13:20

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.