Tutorials ∙ 9 min read
How to Format Currency in Money Transfer App in ProtoPie
Learn how to use the “format()” function to display a number as dollars and cents, pounds and pence, euros, etc.

Jeff Clarke, UX Designer & ProtoPie EducatorJune 29, 2022

Quick Summary

What You’ll Learn
- How to use ProtoPie’s built-in
format()function - How to combine pieces of text together in a formula
- How to automatically show your device’s native keyboard
- How to show the numeric keyboard instead of the regular alphabetic one.
Before You Begin
Step-by-Step
Part 1: Set up the input
- Add an Input layer to your canvas. For now, just position it between the “Transfer amount” layer and the “Continue” button.
- Leave the layer with its default name
Input 1. - We’ll make it hidden later, so don’t worry about size, fonts, colors etc.
- Leave the layer with its default name


- With the input field selected on the canvas, scroll to the bottom of the right-hand properties panel to the “Keyboard Options” section.
- In the “Type” dropdown you can select what keyboard appears when the field is focused. Choose “Number.”


- Add a Start trigger.
- The keypad appears when the Input layer is focused. Add a Focus Response under the Start Trigger to the
Input 1layer, and ensure “Focus In” is selected.

- Uncheck “Tap Return Key”
- Uncheck “Tap outside of Input Layer”

Part 2: Formatting the input for display
- Add a Detect Trigger to the Input layer, and set it to detect changes in
Input 1's Text property.

- Add a Text Response under the Detect Trigger.
- Choose the
Transfer amountlayer. - Under Content, choose “Formula”
- Choose the

- value - the raw number you wish to format — in our case the user’s typed input
- format - a pattern representing how you wish to format the number.
#to represent whole-number portions of the format0to represent decimal portions of the format- a decimal character (e.g.,
.in North America) - a separator character (e.g.,
,as a thousands separator)
format(1234.567, "#")will output1235. No decimal places have been specified in the format, therefore we get only a whole number. Notice how the output is rounded up.format(1234.567, "#,###")will output1,235. This specifies a separator character, and the three successive#characters mean the separator will be used as a thousands separator.format(1234.567, "#,##")will output12,35. It is similar to the above except that the separator is followed by 2 successive#characters, and therefore acts as a hundreds separator.format(1234.567, "#,###.00")will output1,234.57. This ads.as the decimal place character as well as two decimal places. Notice how the output is rounded to the nearest hundredth.format(1234.567, "#.###,00")outputs1.234,57. This is the same as the above format, however, the.is used as the separator character, and the,is used as the decimal place character. This is a common way to format numbers in Europe and other parts of the world.
$1,234.57
- In the Text Response we just created, use the following formula:
"$" + format(Input 1.text, "#,###.00")


"$" + format(Input 1.text / 100, "#,###.00")

.png)


Number Formatting... Easy as Pie!
Want more?
- Documentation: ProtoPie’s built-in Functions
- Tips & Tricks: Create a Typewriter Effect Using Variables and Formulas
- Tips & Tricks: Create a Stopwatch Timer using Formulas and Variables