Hello everyone!
I was hoping y'all could help me out with a small problem. The data set I have has numbers as decimals (i.e. 0.75). I would like it to be presented as a percentage (i.e. 75%) when I use the Render tool to produce a report. I feel like there is a simple solution but I am very new to Alteryx so I thought I would try to use the community! Thank you for any and all help.
Best Regards,
Alex Abi-Najm
Solved! Go to Solution.
Hey @alexnajm,
You'll need to use a Formula tool to create a string value. This will work:
ToString([Percentage]*100)+'%'
To include decimal places in your formatted percentage just use the Round function after multiplying by 100:
ToString(Round(([Percentage]*100),0.1))+"%"
Cheers
Thank you @jamielaird! That worked fantastically.
Best Regards,
Alex Abi-Najm
@jamielaird's solution certainly works, however, I want to point out that the ToString function has the built-in ability to return a specified number of decimal places.
See the help link here -- ToString() Conversion
All this time and I had no idea! Thanks @tom_montpool!
ToString(x, numDec, addThousandsSeparator, decimalSeparator) Converts a numeric parameter to a string using numDec decimal places. By default, the period is used as the decimal separator. ClosedOptional parameters OpenExample ToString(10, 0) returns 10 as a string. ToString(10.4, 2) returns 10.40 as a string. ToString(100.4, 2) returns 100.40 as a string. ToString(1000.4, 2, 1) returns 1,000.40 as a string. ToString(123456.789, 3, 1, ",") returns 123.456,789 as a string. ToString(123456.789, 3, 0, ",") returns 123456,789 as a string.
Full steps to avoid errors when applying formula:
Formula thanks to @jamielaird
1. Use multi-field formula
2. Choose fields to be converted to %
3. Update the Change output type to String (since we are first multiplying your number by 100, then converting this number to a string
Use the formula:
ToString([_CurrentField_]*100)+'%'
Update for Tableau users: If you are outputting Alteryx data to Tableau, keep the data in decimals. Tableau can output the data as percentages. This saves a lot of time and unnecessary conversions.
Although this is marked as "solved", I attempted to do this and, while using the reporting functions in Alteryx to generate charts, this method will result in graphic challenges, since string fields may not display correctly (i.e., lowest numerical value to highest) in a chart when it is now a string.
Hello Jamie,
Great solution!
I was hoping you can answer something for me. I've noticed in formulas sometimes they use single quotes and other times double quotes.
In your response you have 2 solutions. One with single and the other double.
How do I know when to use single quotes vs double quotes?
Thanks in advance for your clarification.
Jose
Hi @jjimenez,
No difference between them - they are interchangeable. The only benefit to using one versus the other is that if you wanted to put out the single vs. double quotes as part of the value (i.e. displaying 'Alex' in a Formula), then you can do " 'Alex' ". Also works the other way!
This works well for words like doesn't - it would need to be "doesn't" to work properly.
-Alex