Is there a formula to convert a float to a percent?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
Solved! Go to Solution.
- Labels:
- Data Investigation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
No problem - you too!
