How to Create a Calculator Using Power Apps

How to Create a Calculator Using Power Apps

Power Apps Canvas Apps allow developers to build interactive business applications with minimal code. One of the best ways to learn Power Apps controls, variables, and Power Fx formulas is by creating a simple calculator application.

In this tutorial, you'll learn how to create a calculator that performs basic arithmetic operations such as addition, subtraction, multiplication, and division.

Why Build a Calculator in Power Apps?

Create the User Interface

Add the following controls to your Canvas App:

Store User Input

Use variables to store numbers and operators.

Set(varValue, "");
Set(varOperator, "");

Configure Number Buttons

For each number button, append the selected digit.

Set(
   varValue,
   varValue & "1"
)

Replace "1" with the corresponding number for each button.

Configure Operator Buttons

Store the selected operator and first value.

Set(varFirstNumber, Value(varValue));
Set(varOperator, "+");
Set(varValue, "");

Calculate the Result

Use the Equals button to perform the calculation.

If(
   varOperator = "+",
   Set(varResult,
       varFirstNumber + Value(varValue)
   )
)

You can extend the formula to support subtraction, multiplication, and division.

Important: Always validate division operations to prevent divide-by-zero errors.

Display the Result

Bind the label Text property to the result variable.

varResult

Common Enhancements

Best Practices

Key Takeaways