# If

## What is the Power Fx If Function?

The Power Fx If function is a conditional statement that enables you to specify a condition and perform an action based on the result. Essentially, it allows you to create an “if this, then that” statement in your application. The syntax for the Power Fx If function is as follows:

``` If(Condition, TrueResult, FalseResult) ```

In this formula, “Condition” is the statement you want to evaluate, “TrueResult” is the action you want to take if the condition is true, and “FalseResult” is the action you want to take if the condition is false.

## How to Use the Power Fx If Function

To demonstrate how to use the Power Fx If function, let’s consider an example. Suppose you want to create an application that calculates the total cost of an order based on the number of items ordered and a discount percentage. The total cost should be calculated as follows:

– If the number of items ordered is less than or equal to 10, the total cost is calculated as Quantity * Price.

– If the number of items ordered is greater than 10, the total cost is calculated as (Quantity * Price) * (1 – Discount).

To implement this functionality, you can use the Power Fx If function. Here’s how:

1. First, create a text input control for the quantity and price of the item, and a slider control for the discount percentage.

2. Next, create a label control that will display the total cost.

3. In the formula bar for the label control, enter the following formula:

``` If(Quantity❰=10, Quantity*Price, (Quantity*Price)*(1-Discount)) ```

This formula uses the Power Fx If function to evaluate whether the quantity is less than or equal to 10. If the condition is true, it multiplies the quantity and price to calculate the total cost. If the condition is false, it multiplies the quantity, price, and discount to calculate the total cost.

4. Finally, save and test your application. Enter different values for the quantity, price, and discount, and observe how the total cost changes based on the number of items ordered and the discount percentage.

The Power Fx If function is a versatile tool that enables you to create custom applications with conditional statements. By using this function, you can build dynamic applications tailored to your specific needs. In this article, we explored how to use the Power Fx If function in Power Apps. We hope this article has been helpful in demonstrating the power of this function and how to use it in your applications.