Free Trial

Alteryx Designer Desktop Discussions

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

Convert number with brackets to negative numbers including the decimal places

Parthasarathi
8 - Asteroid

Hi All,

 

I am trying to convert this (475,971.29) string by replacing the '(' ')' and making it as a positive number using the formula component, but not getting proper output with correct decimal places.

 

IF
StartsWith([Outstanding], '(') AND EndsWith([Outstanding], ')')
THEN
ToNumber('-'+REGEX_REPLACE([Outstanding],'[[:punct:]]|[\$\+<=>\^`\|~]',''), '0')
ELSE
ToNumber([Outstanding],'0')
ENDIF

 

Input: (475,971.29)

Expected output: -475971.29

2 REPLIES 2
Christina_H
14 - Magnetar

I think your RegEx is replacing the decimal point?  You don't need RegEx for this anyway, a simple formula will do it.

 

ToNumber(Replace(Replace([Outstanding], '(','-'), ')',''))

Emmanuel_G
13 - Pulsar

@Parthasarathi  

 

Don't need to use regex.

 

With basics formula functions, you can easily do that. Find the solution attached.

 

Let me know if it works as you want and do not hesitate to mark this answer as solution if it helped.

 

Emmanuel_G_0-1663852155587.png

 

 

 

 

Labels
Top Solution Authors