# How can I get the text of a number in the way one would speak it? For example \$100.00 = One Hundred Dollars

• 0
• Question
• Updated 1 month ago

I could do it with this formula!

var text numt = ToText(Floor([Number]));

var text cents = If(Contains(ToText([Number]), "."), Left(Right(ToText([Number]) & "00", "."), 2),"");

var text teensnum = List(" ",

Case(Floor(ToNumber(Right(\$numt,2))/10),

1, "Ten", 2, "Twenty", 3, "Thirty", 4, "Forty", 5, "Fifty", 6, "Sixty", 7, "Seventy", 8, "Eighty", 9, "Ninety", 0, ""),

Case(ToNumber(Right(\$numt,1)),

1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five", 6, "Six", 7, "Seven", 8, "Eight", 9, "Nine", 0, ""));

var text teens =

If(\$teensnum<>"" and [Number]>99, "and ", "") &

Case(\$teensnum,

"Ten One", "Eleven", "Ten Two", "Twelve", "Ten Three", "Thirteen", "Ten Four", "Fourteen", "Ten Five", "Fifteen", "Ten Six", "Sixteen", "Ten Seven", "Seventeen", "Ten Eight", "Eighteen", "Ten Nine", "Nineteen", \$teensnum);

var text teensnumcents =List(" ",

Case(Left(\$cents,1),

"1", "Ten", "2", "Twenty", "3", "Thirty", "4", "Forty", "5", "Fifty", "6", "Sixty", "7", "Seventy", "8", "Eighty", "9", "Ninety", "0", ""),

Case(Right(\$cents,1),

"1", "One", "2", "Two", "3", "Three", "4", "Four", "5", "Five", "6", "Six", "7", "Seven", "8", "Eight", "9", "Nine", "0", "")

);

var text teenscents =

If(\$teensnumcents<>"", " and ", "") &

Case(\$teensnumcents,

"Ten One", "Eleven", "Ten Two", "Twelve", "Ten Three", "Thirteen", "Ten Four", "Fourteen", "Ten Five", "Fifteen", "Ten Six", "Sixteen", "Ten Seven", "Seventeen", "Ten Eight", "Eighteen", "Ten Nine", "Nineteen", \$teensnumcents)& If(\$teensnumcents<>"", " Cents", "");

List(" ",

If([Number]>=1000000,

Case(Floor([Number]/1000000),

1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five", 6, "Six", 7, "Seven", 8, "Eight", 9, "Nine") & " Million","") & If(Mod([Number],1000000)>0 and [Number]>1000000, ",", ""),

If([Number]>=100000,

Case(Floor(ToNumber(Right(\$numt,6))/100000),

1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five", 6, "Six", 7, "Seven", 8, "Eight", 9, "Nine") & " Hundred","") & If(Mod([Number],100000)>0 and [Number]>100000, " and", "") ,

If([Number]>=10000,

Case(Floor(ToNumber(Right(\$numt,5))/10000),

1, "Ten", 2, "Twenty", 3, "Thirty", 4, "Forty", 5, "Fifty", 6, "Sixty", 7, "Seventy", 8, "Eighty", 9, "Ninety", 0, ""),""),

If([Number]>=1000,

Case(Floor(ToNumber(Right(\$numt,4))/1000),

1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five", 6, "Six", 7, "Seven", 8, "Eight", 9, "Nine", 0, "") & " Thousand","") & If(Mod([Number],1000)>0 and [Number]>1000, ",", ""),

If([Number]>=100,

Case(Floor(ToNumber(Right(\$numt,3))/100),

1, "One Hundred", 2, "Two Hundred", 3, "Three Hundred", 4, "Four Hundred", 5, "Five Hundred", 6, "Six Hundred", 7, "Seven Hundred", 8, "Eight Hundred", 9, "Nine Hundred", 0, ""),""),

\$teens)

& " Dollars" & \$teenscents

• 20 Points

Posted 4 years ago

• 0
• 72,226 Points
Thx for sharing.  I will save that for my next Cheque writing app.
• 0 Points
As usual ... you are da man!
• 50 Points
Hi Sam, I am using the above formula but i noticed one issue if we give single digit number 2 then its returning "and two dollors" :(
Example - Number = 11600 then formula is giving value "Ten One Thousand, Six hundread dollars" ideally it should say "Eleven thousand and Six hundread dollars" ? i am trying to fix it but would be great if you can tell me which variable is causing this issue?

It would be great help if you can provide us the upgraded formula if you have. or atleast can guide me where to make the changes to achieve the goal :)
• 1,678 Points
I noticed this as well, did you get any update on this?
• 1,678 Points
I made some modifications to this calculation so that it could update the teens. I am SURE there are better ways to do this, but I needed it quickly and I didn't want to waste any time cleaning it up. Posting here in case someone else needs it.

var number Value = Round([xxTHENUMERICFIELDxx],0.01);
var text Hundreds=Right(ToText(Int(\$Value)),3);
var text Thousands = If(\$Value>=1000,ToText(Int(\$Value/1000)));
var text Millions = If(\$Value>=1000000,ToText(Int(\$Value/1000000)));

var text numt = ToText(Floor([xxTHENUMERICFIELDxx]));

var text cents = If(Contains(ToText([xxTHENUMERICFIELDxx]), "."), Left(Right(ToText([xxTHENUMERICFIELDxx]) & "00", "."), 2),"");
var text centDecimals = If(Contains(ToText([xxTHENUMERICFIELDxx]), "."),Right(ToText(Int(\$value * 100)),2));

var text teensnumcents = If(\$centDecimals<>"", " and " & List("/",
\$centDecimals,"100")," and No/100") & " Dollars" ;

var text firstNum = Case(Floor(ToNumber(Right(\$numt,2))/10),
1, "Ten", 2, "Twenty", 3, "Thirty", 4, "Forty", 5, "Fifty", 6, "Sixty", 7, "Seventy", 8, "Eighty", 9, "Ninety", 0, "");
var text secondNum = Case(ToNumber(Right(\$numt,1)),
1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five", 6, "Six", 7, "Seven", 8, "Eight", 9, "Nine", 0, "");
var text thirdNum = Case(Floor(ToNumber(Right(\$numt,3))/100),
1, "One Hundred", 2, "Two Hundred", 3, "Three Hundred", 4, "Four Hundred", 5, "Five Hundred", 6, "Six Hundred", 7, "Seven Hundred", 8, "Eight Hundred", 9, "Nine Hundred", 0, "");
var text firstThouNum = If(\$Thousands<>"",Case(Floor(ToNumber(Right(\$Thousands,2))/10),
1, "Ten", 2, "Twenty", 3, "Thirty", 4, "Forty", 5, "Fifty", 6, "Sixty", 7, "Seventy", 8, "Eighty", 9, "Ninety", 0, ""),"");
var text secondThouNum = If(\$Thousands<>"",Case(ToNumber(Right(\$Thousands,1)),
1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five", 6, "Six", 7, "Seven", 8, "Eight", 9, "Nine", 0, ""));
var text thirdThouNum = Case(Floor(ToNumber(Right(\$Thousands,3))/100),
1, "One Hundred", 2, "Two Hundred", 3, "Three Hundred", 4, "Four Hundred", 5, "Five Hundred", 6, "Six Hundred", 7, "Seven Hundred", 8, "Eight Hundred", 9, "Nine Hundred", 0, "");
var text firstMilNum = If(\$Millions<>"",Case(Floor(ToNumber(Right(\$Millions,2))/10),
1, "Ten", 2, "Twenty", 3, "Thirty", 4, "Forty", 5, "Fifty", 6, "Sixty", 7, "Seventy", 8, "Eighty", 9, "Ninety", 0, ""),"");
var text secondMilNum = If(\$Millions<>"",Case(ToNumber(Right(\$Millions,1)),
1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five", 6, "Six", 7, "Seven", 8, "Eight", 9, "Nine", 0, ""));
var text thirdMilNum = Case(Floor(ToNumber(Right(\$Millions,3))/100),
1, "One Hundred", 2, "Two Hundred", 3, "Three Hundred", 4, "Four Hundred", 5, "Five Hundred", 6, "Six Hundred", 7, "Seven Hundred", 8, "Eight Hundred", 9, "Nine Hundred", 0, "");

var text tensNum = List("-", \$firstNum, \$secondNum);
var text thouNum = List("-", \$firstThouNum, \$secondThouNum);
var text millNum = List("-", \$firstMilNum, \$secondMilNum);

var text teensCon = If(Contains(\$tensNum,"ten-")=true,Case(\$tensNum,
"Ten-One", "Eleven",
"Ten-Two", "Twelve",
"Ten-Three", "Thirteen",
"Ten-Four", "Fourteen",
"Ten-Five", "Fifteen",
"Ten-Six", "Sixteen",
"Ten-Seven", "Seventeen",
"Ten-Eight", "Eighteen",
"Ten-Nine", "Nineteen", \$tensNum),\$tensNum);

var text thouCon = If(Contains(\$thouNum,"ten-")=true,Case(\$thouNum,
"Ten-One", "Eleven",
"Ten-Two", "Twelve",
"Ten-Three", "Thirteen",
"Ten-Four", "Fourteen",
"Ten-Five", "Fifteen",
"Ten-Six", "Sixteen",
"Ten-Seven", "Seventeen",
"Ten-Eight", "Eighteen",
"Ten-Nine", "Nineteen", \$thouNum),\$thouNum);

var text millCon = If(Contains(\$millNum,"ten-")=true,Case(\$millNum,
"Ten-One", "Eleven",
"Ten-Two", "Twelve",
"Ten-Three", "Thirteen",
"Ten-Four", "Fourteen",
"Ten-Five", "Fifteen",
"Ten-Six", "Sixteen",
"Ten-Seven", "Seventeen",
"Ten-Eight", "Eighteen",
"Ten-Nine", "Nineteen", \$millNum),\$millNum);

var text teens = \$teensCon;
var text Thouteens = If(\$thouNum<>"" and [xxTHENUMERICFIELDxx]>999, " ", "") & \$thouCon;
var text Milteens = If(\$millNum<>"" and [xxTHENUMERICFIELDxx]>999999, " ", "") & \$millCon;

var text hundredsNum = \$thirdNum &" "& \$teens;
var text hundredsThouNum = \$thirdThouNum &" "& \$thouCon;
var text hundredsMillNum = \$thirdMilNum &" "& \$millCon;

var text finalHund = \$hundredsNum;
var text finalThou = \$hundredsThouNum & " Thousand";
var text finalMill = \$hundredsMillNum & " Million";

//var text finalThouOne = if(Contains(\$finalThou,"Ten-",\$Thouteens,\$finalThou));

If(\$millNum<>"" and [xxTHENUMERICFIELDxx]>999999, \$finalMill, "")&" "&
If(\$thouNum<>"" and [xxTHENUMERICFIELDxx]>999,\$finalThou, "")&" "&
If(\$tensNum<>"" and [xxTHENUMERICFIELDxx]>99, \$finalHund, \$teens) &
if(nz([xxTHENUMERICFIELDxx])<>0,\$teensnumcents,"")
• 70,054 Points
Thank you for posting!
• 1,678 Points
no worries, Sam did all the heavy lifting for this!
• 1,678 Points
quick head's up. My coworkers were able to break this, it does not seem to work if the field being calculated on has more than 10 digits. So if you have a number with a decimal point, it will begin rounding or cutting off the last digit. You can play around to find a good solution, I decided to create two formula fields, one for the decimal, and one for the whole number and then combine the text in a third formula field. good luck!
• 70,054 Points
We would love to see your code!
• 1,678 Points
For the Whole Number:
var number OriginalVal = [xxTHENUMERICFIELDxx];
var number Value = Round(\$OriginalValue,0.01);
var text Hundreds=Right(ToText(Int(\$Value)),3);
var text Thousands = If(\$Value>=1000,ToText(Int(\$Value/1000)));
var text Millions = If(\$Value>=1000000,ToText(Int(\$Value/1000000)));
var text numt = ToText(Floor(\$OriginalValue));

var text firstNum = Case(Floor(ToNumber(Right(\$numt,2))/10),
1, "Ten", 2, "Twenty", 3, "Thirty", 4, "Forty", 5, "Fifty", 6, "Sixty", 7, "Seventy", 8, "Eighty", 9, "Ninety", 0, "");
var text secondNum = Case(ToNumber(Right(\$numt,1)),
1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five", 6, "Six", 7, "Seven", 8, "Eight", 9, "Nine", 0, "");
var text thirdNum = Case(Floor(ToNumber(Right(\$numt,3))/100),
1, "One Hundred", 2, "Two Hundred", 3, "Three Hundred", 4, "Four Hundred", 5, "Five Hundred", 6, "Six Hundred", 7, "Seven Hundred", 8, "Eight Hundred", 9, "Nine Hundred", 0, "");
var text firstThouNum = If(\$Thousands<>"",Case(Floor(ToNumber(Right(\$Thousands,2))/10),
1, "Ten", 2, "Twenty", 3, "Thirty", 4, "Forty", 5, "Fifty", 6, "Sixty", 7, "Seventy", 8, "Eighty", 9, "Ninety", 0, ""),"");
var text secondThouNum = If(\$Thousands<>"",Case(ToNumber(Right(\$Thousands,1)),
1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five", 6, "Six", 7, "Seven", 8, "Eight", 9, "Nine", 0, ""));
var text thirdThouNum = If(\$Thousands<>"",Case(Floor(ToNumber(Right(\$Thousands,3))/100),
1, "One Hundred", 2, "Two Hundred", 3, "Three Hundred", 4, "Four Hundred", 5, "Five Hundred", 6, "Six Hundred", 7, "Seven Hundred", 8, "Eight Hundred", 9, "Nine Hundred", 0, ""));
var text firstMilNum = If(\$Millions<>"",Case(Floor(ToNumber(Right(\$Millions,2))/10),
1, "Ten", 2, "Twenty", 3, "Thirty", 4, "Forty", 5, "Fifty", 6, "Sixty", 7, "Seventy", 8, "Eighty", 9, "Ninety", 0, ""),"");
var text secondMilNum = If(\$Millions<>"",Case(ToNumber(Right(\$Millions,1)),
1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five", 6, "Six", 7, "Seven", 8, "Eight", 9, "Nine", 0, ""));
var text thirdMilNum = Case(Floor(ToNumber(Right(\$Millions,3))/100),
1, "One Hundred", 2, "Two Hundred", 3, "Three Hundred", 4, "Four Hundred", 5, "Five Hundred", 6, "Six Hundred", 7, "Seven Hundred", 8, "Eight Hundred", 9, "Nine Hundred", 0, "");

var text tensNum = List("-", \$firstNum, \$secondNum);
var text thouNum = List("-", \$firstThouNum, \$secondThouNum);
var text millNum = List("-", \$firstMilNum, \$secondMilNum);

var text teensCon = If(Contains(\$tensNum,"ten-")=true,Case(\$tensNum,
"Ten-One", "Eleven",
"Ten-Two", "Twelve",
"Ten-Three", "Thirteen",
"Ten-Four", "Fourteen",
"Ten-Five", "Fifteen",
"Ten-Six", "Sixteen",
"Ten-Seven", "Seventeen",
"Ten-Eight", "Eighteen",
"Ten-Nine", "Nineteen", \$tensNum),\$tensNum);

var text thouCon = If(Contains(\$thouNum,"ten-")=true,Case(\$thouNum,
"Ten-One", "Eleven",
"Ten-Two", "Twelve",
"Ten-Three", "Thirteen",
"Ten-Four", "Fourteen",
"Ten-Five", "Fifteen",
"Ten-Six", "Sixteen",
"Ten-Seven", "Seventeen",
"Ten-Eight", "Eighteen",
"Ten-Nine", "Nineteen", \$thouNum),\$thouNum);

var text millCon = If(Contains(\$millNum,"ten-")=true,Case(\$millNum,
"Ten-One", "Eleven",
"Ten-Two", "Twelve",
"Ten-Three", "Thirteen",
"Ten-Four", "Fourteen",
"Ten-Five", "Fifteen",
"Ten-Six", "Sixteen",
"Ten-Seven", "Seventeen",
"Ten-Eight", "Eighteen",
"Ten-Nine", "Nineteen", \$millNum),\$millNum);

var text hundredsNum = \$thirdNum & If(\$teensCon<>""," "& \$teensCon,"");
var text hundredsThouNum = \$thirdThouNum & If(\$thouCon<>""," " & \$thouCon,"");
var text hundredsMillNum = \$thirdMilNum & If(\$millCon<>"", " "& \$millCon,"");

var text finalHund = Trim(\$hundredsNum);
var text finalThou = Trim(\$hundredsThouNum & " Thousand");
var text finalMill = Trim(\$hundredsMillNum & " Million");

var text finalNumber = if(Floor(\$OriginalValue)<=0,"Zero",
If(\$hundredsMillNum <> " " and \$OriginalValue>=1000000, \$finalMill, "")&
If(\$hundredsThouNum <> "" and \$OriginalValue>=1000," "& \$finalThou, "")&
If(ToNumber(\$Hundreds)<>0 and \$OriginalValue>=99," "& \$finalHund, \$teensCon));

Trim(\$finalNumber)
• 1,678 Points
The cents can be done the same way, with the formula only reading up to the tenths place instead of up to millions. In my case, I needed only the digits to display in the following matter: xxx and 12/100 dollars. Therefore, I only had to grab the two digits and verify it didn't attempt to round them etc.

var number Split = Frac([xxTHENUMERICFIELDxx]);
ToNumber(Left(Right(ToText(\$Split)&"0","."),2))

This formula reliably grabs the single or double digit after the decimal point, and keeps them exactly as is. I am adding a calculation that also adds a 0 after a digit to protect against user error. Ex. \$100.2 should behave like \$100.20. By adding a 0 after every number that is grabbed, I can confidently pull back a two digit number. whew. The final formula just adds [formula field 1] & "." & [formula field 2].
I am at Empower, so if anyone wants to chat, find me on the app!
• 70,054 Points
Thx for posting. I’m here @ Empower too. (Mark Shnier)
• 1,678 Points
just messaged you on the empower app!