String Manipulation multiple columns follow up

Hi @takbb,
I hope you don’t mind me tagging you directly.

I found the below forum post which is the closest I have come to solving my particular issue.

Within a loop, I need check the value in a series of string columns and if the value equals exactly ‘%’, I need to replace it with a missing value or Null.

Other rows in the same columns may include the ‘%’ sign and I need to keep these as is (Example data below).
image

Using your example, i’ve updated the expression as below which successfully recognises the % and replaces it (see screenshot below) :

string(
$$CURRENTCOLUMN$$.equals(“0”)
?“”
:$$CURRENTCOLUMN$$.equals(“1”)
?“yes”
:$$CURRENTCOLUMN$$
)

image

However, in your expression, I don’t actually need the section that returns the value ‘yes’. I just need to keep the value that was already present. I’ve tried to re-write the ‘yes’ section of the expression to reflect this, in addition to trying other variations of it, but i keep encountering errors.

If possible, do you know how can i update the expression to achieve the desired result please?

Thanks in advance for your help.

Pete

Hi @taylorpeter55

Yes this should be achievable. Instead of the line
?"yes"
use
?$$CURRENTCOLUMN$$

So in fact the entire equivalent to replace “%” with empty string and leave everything else, would be:

string(
$$CURRENTCOLUMN$$.equals("%")
?""
:$$CURRENTCOLUMN$$
)

and if you wanted it to have it return null (missing) rather than an empty String:

string(
$$CURRENTCOLUMN$$.equals("%")
?toNull("")
:$$CURRENTCOLUMN$$
)
3 Likes

@takbb,

Thanks so much - your help is greatly appreciated.

I’ve marked this as the solution.
Thanks
Pete

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.