# 1000000 to 1M and 1000 to 1K

1000000 to 1M and 1000 to 1K

or 10000 to 1P / 120,000 to 12P / 560,000 to 56P

Is it possible to convert it? using function

thanks

There’s not a single magic function to do this, but you can set up a series of conditional cases using the same basic formula. (I checked Stack Overflow for how this would be done in “real” code like javascript, and the best solutions were functions that essentially took the same approach.)

The basic formula is to divide “millions” by “one million” and append an ‘M’, else divide “thousands” by “one thousand”, etc. Using your first example, this would need at least three conditional cases:

• If Value is greater than or equals 1000000, Set Text (or Set Variable) to
`[[ (Value / 1000000).toFixed()]]M`
• Else If Value is greater than or equals 1000, Set Text to
`[[ (Value / 1000).toFixed()]]K`
• Else Set Text to Value

Note: the .toFixed() function is not absolutely required, but it will keep the results to whole numbers, so values like, 1000 or 1200 or 1234 or 1000.00 would all result in “1K” instead of “1.234K”. You can change the precision, where .toFixed(1) would mean that 1000 = 1.0K, 1200 = 1.2K, 1234 = 1.2K, etc.

If you want 10000 to result in “1P” the expression (forumula) would be
`[[ (Value / 10000).toFixed()]]P`

However, if the source number contains commas those need to be stripped out first. It is weird, but Axure recognizes 1,000 as a number, but if you try to perform logic or math with it, it treats it like a string, not a number. So, “1,000” does not really equal “1000”. To convert this, you can use the .replace() function like so:
`[[String.replace(',', '')]]`
…which means “replace all commas with nothing”

Here is a little demo showing this in RP:
Convert numbers to abbreviations.rp (51.8 KB)

2 Likes

Thank you for your kind reply.
I will study hard and contribute to the Korean axure Community.