How to Use the Power Fx ErrorĀ  Function in Power Apps

What is the Power Fx Error Function?

The Error function is a built-in function provided by Power Fx that allows developers to handle errors in their apps gracefully. It returns an error value that can be used to check if an operation has succeeded or failed. The Error function takes two arguments, the error code, and the error message.

Syntax of the Power Fx Error Function

Error(errorCode, errorMessage)

The `errorCode` argument specifies the error code, which is a number that uniquely identifies the error. The `errorMessage` argument is a string that provides additional information about the error.

How to Use the Power Fx Error Function in Power Apps

To use the Power Fx Error function in Power Apps, follow these steps:

Step 1: Open your Power App

First, open your Power App in the Power Apps Studio.

Step 2: Add a control

Next, add a control to your app. You can use any control of your choice.

Step 3: Add a formula

In the formula bar of the control, add the following formula:

If(1=2, "This will never be true", Error(1, "Something went wrong!"))

This formula will return an error with the error code “1” and the error message “Something went wrong!”.

Step 4: Test the formula

To test the formula, save and publish your app. Then, open the app and interact with the control that contains the formula. You should see the error message displayed.

Step 5: Handle the error

Now that you know how to generate an error using the Power Fx Error function, you can handle the error in your app. To do this, you can use the IfError function, which checks if a formula returns an error and performs an action accordingly.


If(1=2, "This will never be true", Error(1, "Something went wrong!")),

"No errors found"


In this example, the IfError function will check if the formula returns an error. If it does, it will return the error message. If it doesn’t, it will return the message “No errors found”.

The Power Fx Error function is a powerful tool that enables developers to handle errors in their apps efficiently. By understanding how to use this function, you can create better apps that are more reliable and user-friendly. So, next time you develop an app in Power Apps, don’t forget to use the Power Fx Error function to handle errors gracefully.

Power Apps Training Courses by G Com Solutions (0800 998 9248)