Alteryx Designer Desktop Discussions

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

Is there a formula to convert a float to a percent?

bjemison
7 - Meteor

Hello all,

 

So I am already aware that I can easily change the data type for a field by dragging in the Select tool and then changing the type. However I don't want to convert all of the numbers in my Rate column to a percent. I have another column that indicates "flat rate" or "percent" and I only want to convert the numbers that have "percent" in this other column. I tried looking for something similar to the ToString() function, but instead of ToString it would be like ToPercent. Then I could write a formula like:

IF [Flat Rate vs Premium] = "Percent"

THEN ToPercent([Rate])

ELSE([Rate])

 

 

I can't seem to find an easy way of doing this. Any suggestions?

3 REPLIES 3
DavidThorpe
Alteryx
Alteryx

Hi @bjemison 

 

All values in an output field must be of the same type - if you wish them to be percentage format i.e. '97.7%', then the field must be a string type.

 

To achieve this you can create a new field with the formula

 

IF [Flat Rate vs Premium] = "Percent"

THEN tostring([Rate])+'%'

ELSE tostring([Rate])

ENDIF

 

Additionally, you can add a *100 statement if your raw data is of format 0.977 (i.e. tostring([Rate]*100)+'%')

 

You can also control the number of decimal places in your percentage output, through the process on the below article:

https://community.alteryx.com/t5/Alteryx-Knowledge-Base/Currency-formula-or-adding-the-comma-separat...

 

If you want your output to be numeric (float, double etc.) then you will not be able to suffix the '%', as these characters are not supported in numeric field types.

 

Thanks

bjemison
7 - Meteor

Hi David,

 

You're right. That makes sense that we can't have different data types in the same column. Good point. I like the alternative that you suggested. Thank you for answering and have a great day!

DavidThorpe
Alteryx
Alteryx

No problem - you too!

Labels