Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
ALTER.NEXT:

Join us on Dec 2 for a half-day virtual analytics + data science event!
US & CA customers only

SAVE YOUR SPOT
It's the most wonderful time of the year - Santalytics 2020 is here! This year, Santa's workshop needs the help of the Alteryx Community to help get back on track, so head over to the Group Hub for all the info to get started!

Formula to add the prefix B when it is numeric value only

Highlighted
8 - Asteroid

We are using the below formula to add the prefix B if the value in the column is whole number, but this formula is not working correctly as it is just looking at the first value not the whole value. For example if value is 1A219 it should add the prefix B as it contains alpha as well. We are expecting only the B prefix to be added if the value is whole number i.e. 64972 not alpha numeric. Please advise

 

IF ToNumber([Counterparty]) >0 then "B"+[Counterparty] else [Counterparty] endif

Highlighted
16 - Nebula
16 - Nebula

How about using this formula?

 

if REGEX_Match([Counterparty], '\d+') then "B"+[Counterparty] else [Counterparty] endif

Highlighted
16 - Nebula
16 - Nebula

The ToNumber function parses the string as far as it can - i.e. 1A234 becomes 1.

 

I suggest:

IF REGEX_Match([Counterparty], "^[0-9]+$") then "B"+[Counterparty] else [Counterparty] endif

This checks the string is purely numerical.

Labels