We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Removing ending zeros

Adam_B
8 - Asteroid

Hello, 

I have a formula to convert a V_Wstring to Currency:

Adam_B_0-1680815662369.png

However, the result has many zeros at the end.  How do I resolve this issue?  Tried searching forums and none are helping. 

 

Thanks, 

Adam 

4 REPLIES 4
binuacs
21 - Polaris

@Adam_BThere are multiple ways we can remove the zeros but before that can you check your input amount field has many zeros at the end? Also can you confirm the data type of this field in the input file also would you be able to provide some input data and expected output?

martinding
13 - Pulsar

Hi @Adam_B,

 

Based on this formula, we can see that you are trying to update the same field, which is already a string.

 

You don't actually need to use "ToString()" on the string field. You can simply "$" + [sum(Requisition Spend)]

 

In the case where your original string doesn't contain separators or decimals, e.g. 157156.

Then you could do this:

martinding_0-1680823781402.png

 

danilang
19 - Altair
19 - Altair

Hi @Adam_B 

 

It looks like ToString() will only apply the formatting config if the input value is NOT a string.  If the input value is a string, ToString() just passed the input value, unmodified.

 

danilang_0-1680871117007.png

OutFromInt is the result of using ToString([Sum(Requisition Spend)], 2,1) on the initial input value which is a double

OutFromString is the result of using ToString([Sum(Requisition Spend)], 2,1) after [Sum(Requisition Spend)] is converted to a string.

 

You can either convert your input field to a double with ToNumber before applying ToString or check the formula that initially creates [Sum(Requisition Spend)] and ensure that it's return type is a double.

 

If [Sum(Requisition Spend)] comes in from an input tools as a string, you can use Regex_Replace([Sum(Requisition Spend)],"(.*)\.\d*","$1.00") to truncate it to two decimal places

 

Dan

Adam_B
8 - Asteroid

@martinding Thank you! That was perfect. 

Labels
Top Solution Authors