Jump to content

Calculation Within Script Required Please


This topic is 4377 days old. Please don't post here. Open a new topic instead.

Recommended Posts

If I have a field that contains values such as:

01 08 14 22 Q

Can I write a script step such as 'Insert Calculated result' that will remove the 'Q' from this field and leave the other numbers in the field? There can different numbers in different quantities separated by a space. If it helps the 'Q' will always be the last value in the field. I was thinking one of the following functions such as PatternCount, Replace or Substitute may help.

Link to comment
Share on other sites

Hi adyf,

You are correct in that the Substitute function can be used. if you are confident that the values in the fields always follow the same formatting, and, and that Q will be the last value in the list, you can use the following substitute formula:

Substitute ( YourField ; " Q" ; "" )

This will replace all occurrences of a space followed by a Q, and remove it essentially. Note that the substitute function is case sensitive, so if you cannot guarantee the case of the Q, try:

Substitute ( YourField ; [ " q" ; "" ] ; [ " Q" ; "" ] )

The substitute function as mentioned is for your ideal case, it may fail if the Q is in any other place in the field.

You can then use the Replace Field contents script step to perform this replace on every record in your found set. Use it with the calculation option & use the substitute function in there.

Link to comment
Share on other sites

Having multiple "facts" per field is often a sign of poor design. Shouldn't each of these values be a separate record?

However, if you wish to strip the Q, and it's always the last value, then newField= left ( origField; length (origField)-1)

Use this approach if you wish to maintain the origField rather than Replace.

Link to comment
Share on other sites

This topic is 4377 days old. Please don't post here. Open a new topic instead.

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
 Share

×
×
  • Create New...

Important Information

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