Alteryx Designer Desktop Discussions

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

Error: Decimal place issue when converting Double to String to add '%' symbol suffix

madhurinani
8 - Asteroid

Hello,

Below are the requirements:

I need to substract 2 percentage columns (current FD Own %) and (pq) column and find out the difference and then add the % symbol to display as a percentage substraction.

I was able to do that and create a new column= Change.

 

Now to add the % symbol at the end, i belive i need to convert the Double data type into a string and use the TOSTRING function to add that symbol.

When I add that I see that my 2 decimal places are now becoming like 10,12. 

 

Can anyone help me in that?

The highlighted part of the screenshot is where I see the issue.

I have also attached with workflow file.

 

6 REPLIES 6
DataNath
17 - Castor
17 - Castor

@madhurinani you should just be able to do it all in one step with a Formula like the following, without the need to change datatypes etc for the sake of getting the right display (obviously replacing my dummy fields with your own):

 

DataNath_0-1656933667477.png

 

Ladarthure
14 - Magnetar
14 - Magnetar

Hi @madhurinani,

 

to do this, you can directly use a formula and create a new text field using a formula like this one : 

 

tostring (
[val_Number] * 100,
2)+'%'

 

it will convert the value in string, then I did a simple calculation on a field. It works perfectly on my side, you may want to use a round function before though.

 

Hope it helps.

binuacs
21 - Polaris

@madhurinani I updated your workflow by making the below changes 

binuacs_0-1656972306255.png

 

madhurinani
8 - Asteroid

Hello All,

I am still facing the error as noticed by the client recently.

Step 1: I have created a new category column which is an nested if-else condition. Hence all the columns are in DOUBLE format. Works fine as expected.

Step 2: I convert the 3 columns in STRING as I need to append % symbol. (image attached)

Step 3: I create 3 formulas to append the %symbol for all the columns. 

 

Problem: When I use the step 2 SELECT logic to convert the from DOUBLE to STRING, my values in the Change column change.

Attached pics.

 

How Can i resolve this issue. Any help would be appreciated.
Ideally the value should be 0.08% only

 

Thanks.

calebdugger
7 - Meteor

I don't believe there is any reason to add the "Select" tool as that's not how you'd want to change it to a String field. I had a similar scenario just today.

The field was numeric, but I wanted to change to a string so I could add a '%' to the end.

I tried the first screenshot first and it wouldn't work because the "Data type" was still a numeric type, but you can update it right on the "Formula" tool as you see in the second screenshot.

As you can see, it worked like I wanted it to after that. Hopefully this helps!

 

#1 = Showed an Error 

calebdugger_2-1657753433996.png

 

#2 = Worked great!

calebdugger_3-1657753490998.png

 

 

 

madhurinani
8 - Asteroid

madhurinani_0-1657806450385.png

@calebdugger : I tried your logic and its not working. My data type is DOUBLE and I used your formula to convert into a STRING. It shows a Parse Error at char error.

I tried both ways, adding a new column as well as editing the same column. 

Labels
Top Solution Authors