Advent of Code is now back for a limited time only! Complete as many challenges as you can to earn those badges you may have missed in December. Learn more about how to participate here!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

regex help

jessy_chow
8 - Asteroid

how can I write a regex syntax to remove the "-" at the end and convert the number to a negative figure?

Currently the Amount Column is a V_String due to the hyphen at the end. I want to remove the hyphen then convert the cell to a double and make it a negative. I have been playing with the regex syntax to remove the hyphen but have had no luck. Thanks! 

jessy_chow_3-1750365062762.png

 

 

jessy_chow_1-1750364962192.png

 

 

 

 

 

6 REPLIES 6
MilindG
12 - Quasar

MilindG_0-1750365622210.png

Can you just use replace function?

binuacs
21 - Polaris

@jessy_chow Regex Version

binuacs_0-1750370439401.png

 

caltang
17 - Castor
17 - Castor

Another way - if you just want to remove it at the end, is to use a multi field formula tool with the following expression:

 

IF EndsWith(ToString([_CurrentField_]),”-“)

THEN ToNumber(LEFT(ToString([_CurrentField_]), LENGTH(ToString([_CurrentField_]))-1))

ELSE ToNumber([_CurrentField_])

ENDIF

 

Make sure to select the field of interest and turn off the Copy output fields and add function, and change the output type to Double.

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
jessy_chow
8 - Asteroid

Thanks! This worked!


jessy_chow
8 - Asteroid

Thank you! This worked ....very slowly learning regex syntax. 

jessy_chow
8 - Asteroid

Thanks! Will try this out! 

Labels
Top Solution Authors