cancel
Showing results for
Did you mean:

## Number to word conversion tool

Currently there is no out-of-box feature available in PowerApps and Flow to convert a numerical value into word and hence this blog walks you through how to build one. This blog is an extension of Brian Dang's 'Expanded Word Form for place value' blog.

Scenario:
A scenario I came across was to take a numerical dollar value and convert that into a word form to be printed on pre-printed checks. Hence I created a screen which has the numerical value, the word form and the full name of the person. This blog only focuses on the numerical to word conversion piece.

Video:

Formulas:

Set(WholeNumberVar, First(Split(TextInput.Text,".")));If(!IsBlank(Find(".",TextInput.Text)),Set(DecimalNumberVar,Last(Split(TextInput.Text,"."))),"");

Clear(expandedForm);

// Create a table that separates each digit to include its Value and Position. Make a placeholder for its Place and Period.
ForAll(RenameColumns(Split(WholeNumberVar.Result,""),"Result","Char"),
Collect(expandedForm,
{
Value: Value(Char),
Position:
// Determine the position of each character as a difference between the length of the number and how many digits have already been collected.
Len(WholeNumberVar.Result)-CountRows(expandedForm),
Place: 0,
Period: 0
}
)
);

// Update the Place and Period using the Position.
ForAll(RenameColumns(expandedForm,"Position","Pos"),
Patch(expandedForm,LookUp(expandedForm,Pos=Position),
{
Place:
// Determine if a given column is a one, ten, or hundred based on its position.
Switch(true,
Mod(Pos-1,3)=0,1,
Mod(Pos+1,3)=0,10,
100
),
Period:
// Determine what Period a digit belongs to based on its position.
RoundUp(Pos/3,0)-1
}
)
)

If(IsBlank(Find(".",TextInput.Text)),
Concatenate(
Concat(
GroupBy(expandedForm,"Period","PeriodGroup"),

// Read the hundred in the period.
LookUp(PlaceValue_1,Digit=LookUp(PeriodGroup,Place=100).Value,Word & " ") &

// For 10-19, read the tens and ones together, otherwise separately.
If(LookUp(PeriodGroup,Place=10).Value=1,
LookUp(PlaceValue_1,Digit=Value(Concat(Filter(PeriodGroup,Place<>100),Text(Value))),Word & " "),
Concat(Filter(PeriodGroup,Place<>100),LookUp(PlaceValue_1,Digit=Value && Column=Place,Word & " "))
) &

Coalesce(LookUp(Period_1,Group=Period,Name & ", "),"")),"dollars"),
Concatenate(
Concat(
GroupBy(expandedForm,"Period","PeriodGroup"),

// Read the hundred in the period.
LookUp(PlaceValue_1,Digit=LookUp(PeriodGroup,Place=100).Value,Word & " ") &

// For 10-19, read the tens and ones together, otherwise separately.
If(LookUp(PeriodGroup,Place=10).Value=1,
LookUp(PlaceValue_1,Digit=Value(Concat(Filter(PeriodGroup,Place<>100),Text(Value))),Word & " "),
Concat(Filter(PeriodGroup,Place<>100),LookUp(PlaceValue_1,Digit=Value && Column=Place,Word & " "))
) &

Coalesce(LookUp(Period_1,Group=Period,Name & ", "),"")
),Concatenate("dollars & ",DecimalNumberVar.Result,"/100 cents")))

Here's what the expandedForm collection looks like

Conclusion:

As mentioned in the video this app is an extension of Brian Dang's app which uses Components. Attached is a zipped file contains a copy of both the Excel spreadsheet and the MSAPP file which you can use.

Very useful, thanks.

@darogael this is great! However for 1 000 000 the wording comes out as one million thousand dollars rather than one million dollars. Been trying to troubleshoot the code with no luck yet.

The collection for expandForm is not given here and it is one of the steps that you overlooked in your video.

While thanking @darogael for the code,

@ldskfklodsf  Yes, You are right! I wrote a simple script to correct the result phrase. Maybe it is not the best solution but it is fast.

Just, I removed the extra words! Even by following steps, it will be easier to understand my explanation.

You may add another "Label" to the screen and put the following code to the Text field.

Here is the code:

``````//to remove extra ", million" & ", billion" & ...
Substitute(Substitute(Substitute(Substitute(Substitute(WordLabel.Text,", thousand,",""),", million",""),", billion",""),", trillion",""),", quadrillion","")``````

Or

``````//to remove extra ", million" & ", billion" & ...
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
WordLabel.Text,
", thousand,",
""
),
", million",
""
),
", billion",
""
),
", trillion",
""
),
""
)``````

Here is the result:

Thanks @MR_Malakooti . The adjustment was very helpful. I need some help if you will be so kind in translating the figures after the periods to words as well. So in your example it will be one billion dollars and twenty five cents(1000000000.25)

Hello, I tried your app, is very useful..,

trying the input text.., I noted it is not working when I write the number 20, 22, 23, ....,

I already checked the excel file out, but I could not find any solution...,

please if you could tell us how to do that..,

thank you

I made invoice system in power apps and i want to display word format in label but which field i want to convert in to word is also calculated field and your code is not work on it.

Hi Daniel,

I have two requests in this regard:

1- In power app, how to do this for amount field appearing in gallery?

2- If amount field is existing in the share point list, is there a way to convert it to text in a flow? so I can use 'update item' function to write the result back to the list item?

@darogael - I'm getting Lookup has invalid arguments. Am I missing anything here ?

Meet Our Blog Authors
• PowerApps Community Mentor 2018, Practicing surgeon and former Professor of Surgery, University of Illinois, Chicago.
• I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
• Systems developer
• My name is Timothy Shaw and I create digital solutions using the Power Platform, Office 365, and Azure SQL and handle the IT for a small company in the energy sector. When not building the future :), I enjoy playing guitar, good (or really bad!) sci-fi, Xbox therapy, and hanging with my wife and son. Twitter: @ShortForTim
Top Kudoed Posts
Latest Articles
Archives