Power Apps if function allows you to perform conditional logic within your app. It evaluates a condition and returns one value if the condition is true and another value if the condition is false.
In this tutorial, I will tell you what the if condition in Power Apps is, how to use the if condition in PowerApps, and PowerApps if statement syntax.
Also, we will discuss how to work with PowerApps if statement multiple actions, PowerApps if multiple conditions, Power Apps If statement in gallery items, PowerApps if else dropdown value, and many more like:
- Power Apps IF Function Text Examples
- Power Apps IF Function Number Examples
- Power Apps IF Function Boolean Examples
- Power Apps IF Function Date Examples
- Power Apps IF Function Choice Column Examples
- Power Apps IF Function Person Column Examples
- Power Apps IF Function Lookup Column Examples
- Power Apps IF Statement OR
- Power Apps IF Statement AND
- Power Apps IF Statement NOT
- Power Apps IF Statement Multiple Logical Operators
Power Apps IF Function
Power Apps If function specifies whether one or more conditions in a set are true. If the result is true, the corresponding value is returned. If no result is found, the default value is returned.
Power Apps IF Function Syntax:
1. If( Condition, ThenResult [, DefaultResult ] )
2. If( Condition1, ThenResult1 [, Condition2, ThenResult2, ... [ , DefaultResult ] ] )
Where,
- Condition(s) = This is required. Formula(s) to test for true. Such formulas commonly contain comparison operators (such as <, >, and =) and test functions such as IsBlank and IsEmpty
- ThenResult(s) = This is also required. The corresponding value to return for a condition that evaluates to true
- DefaultResult = This is an optional. The value to return if no condition evaluates to true. If you don’t specify this argument, a blank is returned
Power Apps IF and Switch Function
The Powerapps If and Switch functions are mostly similar. However, you need to choose a specific function according to your requirements. Have a look at the table below.
Power Apps IF Condition | Power Apps Switch Condition |
You can use the If function to execute a single condition. You may know the most common syntax for the If function is: If( Condition, ThenResult, DefaultResult ) defined as the “if…then…else…” pattern | It specifies whether the result matches any value in a set. If a match is found, the corresponding value is returned. If no match is found, a default value is returned |
You can use the If function to execute multiple conditions. You can specify multiple conditions without having to nest if formulas | You can use the Switch function to execute a single condition against the multiple possible matches. To repeat the formula for each possible match, you can also use the If function |
The IF function is suitable for simple conditional statements where you only need to evaluate one condition | The Switch function is more suitable for scenarios where you have multiple possible outcomes based on different values of an expression |
Power Apps Switch Function Syntax:
Switch( Formula, Match1, Result1 [, Match2, Result2, ... [, DefaultResult ] ] )
Where,
- Formula = This is required that specifies the formula to evaluate for matches. This formula is evaluated only once
- Match(s) = This is also required to define values to compare with the formula’s result. If an exact match is found, the corresponding result is returned
- Result(s) = This is required where the corresponding value is returned when an exact match is found
- DefaultResult = This is optional. If an exact match isn’t found, this value is returned. If you don’t specify this argument, a blank is returned
Power Apps If Condition Example
In Power Apps, there is a Text input control and a Button control. If the text input value is equal to “Premium,” the button control will be visible; otherwise, it will be in disable mode.
To do so, follow the below steps. Such as:
1. On the Power Apps Screen, insert a Text input control, set its Default property to blank, and set its Hint Text property to “Enter Subscription Plan.”
2. Now, insert a Button control and set its Visible property to the code below.
Visible = If(
txt_Subscription.Text = "Premium",
true,
false
)
Where,
- txt_Subscription = Power Apps text input name
- “Premium” = Text input value
3. Once your app is ready, Save, Publish, and Preview the app. When the user adds the text value “Premium” in the text input control, the button control will be visible; Otherwise, it will be in disable mode.
Output:
Power Apps If Statement Multiple Conditions
Here, we will see how to use multiple if statements simply. As you know, you can apply the formula below for one condition.
If(<condition 1>, <result if true>, .... , <default value>)
Similarly, suppose you want to apply two or multiple conditions in one If statement; then you can use the && operation instead of nested If statements.
Example:
Let’s say you have a Power Apps app where you want to display different messages based on the value of a variable called QuizeScore. Depending on the value of QuizScore, you want to display one of the following messages:
- If QuizScore is greater than or equal to 9, display “Excellent!”
- If QuizScore is greater than or equal to 8, display “Good job!”
- If QuizScore is greater than or equal to 7, display “Keep it up!”
- If QuizScore is less than 7, display “You can do better!”
You can achieve this using nested If statements like so:
If(
QuizScore >= 9,
"Excellent!",
If(
QuizScore >= 8,
"Good job!",
If(
QuizScore >= 7,
"Keep it up!",
"You can do better!"
)
)
)
Note:
Another important thing you should know is that you can only nest 50 If statements. If you reach this limit, you’re overcomplicating the overall formula
Power Apps If Statement Multiple Actions
Suppose you want to chain multiple functions in a true case of an if statement by using “;” as a delimiter. In the locale, “;” is the default delimiter. Then, which delimiter can you use to execute multiple statements for the if true branch?
To answer this question, if you will use a “,” between arguments in your formula, then “;” is used to separate different statements. It has to do with local settings.
As simple as You can use the ‘;;’ character pair to separate multiple statements, something along the lines of the expression below:
If(
txt_Value.Text = "";
Set(isEmpty, true);; Set(isError, true);; Set(another: 123);
Set(isEmpty, false);; SubmitForm(EditForm1))
Power Apps If Statement in Gallery Items
I have a SharePoint Online list named “Employee Onboarding,” and this list contains the below fields.
Column Name | Data Type |
Employee ID | It is a default single line of text |
Name | A single line of text |
A single line of text | |
Gender | Choice |
Joining Date | Date and time |
Department | Lookup |
In Power Apps, there is a Gallery control and a Radio button control. The Radio button control retrieves the SharePoint list look field values, including the “All” value.
If the user selects the “All” value from the radio button, the gallery will display all the SharePoint list records.
In the same way, if the user selects any other value from the radio button, the gallery filters and displays each record from the SharePoint list based on the radio button selected value.
Output:
To do so, follow the below steps.
1. Select the Power Apps Screen and set its OnVisible property to the code below:
OnVisible = ClearCollect(
colEmployees,
{Value: "All"}
);
Collect(
colEmployees,
Distinct(
Departments,Title
)
)
Where,
- colEmployees = Power Apps collection name
2. Then, insert a Radio button control and set its Items property as:
Items = colEmployees
3. Insert a Gallery control and set its Items property as:
Items = If(
Radio_Departments.Selected.Value = "All",
'Employee Onboarding',
Filter(
'Employee Onboarding',
Department.Value = Radio_Departments.Selected.Value
)
)
Where,
- Radio_Departments = Power Apps Radio button name
4. Save, Publish, Reload, and Preview the app. The gallery control filters and displays the SharePoint list records based on the Radio button Lookup selected value like below.
This way, you can work with the Power Apps If statement in gallery items.
Power Apps If Statement Dropdown Value
Next, we will discuss how to use Powerapps If statement dropdown value with a simple example.
Example:
In Power Apps, there is a Dropdown control and a Button control. When you select the Dropdown values “Power Apps” and “Power Automate,” the Button will be visible. Otherwise, it will be invisible.
Output:
To do so, follow the below steps.
1. On the Power Apps Screen, insert a Dropdown control and set its Items property to the code below.
Items = ["Power Apps", "Power BI", "Power Automate", "SharePoint Online"]
2. Next, insert a Button control and apply the below formula on its Visible property as:
Visible = If(
drp_Items.Selected.Value = "Power Apps" || drp_Items.Selected.Value = "Power Automate",
true,
false
)
Where,
- drp_Items = Power Apps dropdown control name
3. Finally, Preview the app. Once the user selects the Dropdown values as “Power Apps” and “Power Automate,” the Button will be visible. Otherwise, it will be invisible, as shown below.
This is how we can work with the Powerapps If statement dropdown value.
Power Apps IF Function Text Examples
Now, I will show you how to work with the Power Apps If function text examples. Such as:
IF Text Value Equals
Suppose you want to display the button control based on the text input value equal to “Premium.” In this case, you can use the below code for the Button control’s Visible property.
Visible = If(
txt_Subscription.Text = "Premium",
true,
false
)
IF Text Value Contains
Input:
Set(varText, "Microsoft Power Platform")
Code:
You can check if variable [varText] contains “Microsoft” using the below.
If("Microsoft" in varText, true, false)
Output:
true
IF Text Value StartWith
Input:
Set(varText, "Microsoft Power Platform")
Code:
You can check if variable [VarText] startwith “Microsoft” using the below.
If(StartsWith(varText,"Microsoft"), true , false )
Output:
true
IF Text Value Blank()
Input:
Set(varText, Blank())
Code:
You can check if variable [VarText] contains “Microsoft” using the below.
If(IsBlank(varText),true,false)
Output:
true
IF Text Value Equals Multiple Conditions
Input:
Set(varText, "Microsoft Power Platform")
Code:
You can check with multiple conditions and return the result where “varText” is equal to “Microsoft Power Platform” using the below.
If(varText="Microsoft",true,varText="Microsoft Power Platform",true)
Output:
true
This way, you can work with the Power Apps If function text examples.
Power Apps IF Function Number Examples
In this section, we will discuss Power Apps if function number examples. Such as:
IF Number Value is Greater Than Or Less Than
Suppose you want to display the text label message [Order Many More!] based on the text input value [If the product quantity is less than 3].
To do so, follow the below code for the Text label’s Text property.
Text = If(Value(txt_Number.Text)<3, "Order Many More!")
IF Number Value is Greater Than Or Equals To/ Less Than Or Equals To
Input:
Set(varQuantity, 9)
Code:
You can check if the variable is greater than or equal to 7 using the below.
If(varQuantity >= 7, true, false)
Output:
true
IF Number Value is Between Two Values
Input:
Set(varQuantity,5)
Code:
You can check if the variable is between 3 and 7 using the below.
If(
varQuantity >= 3
varQuantity <= 7,
true,
false
)
Output:
true
IF Number Is Found Using Multiple Conditions
Input:
Set(varQuantity, 9)
Code:
You can check the multiple conditions and return the result where the variable is greater than 7 but less than 13 using the below.
If(
varQuantity > 7,
"Your Order is Selected For Discount",
varQuantity <= 13,
"No Stock"
)
Output:
"Your Order is Selected For Discount"
IF Number Value Does Not Equal
Input:
Set(varQuantity, 4)
Code:
You can check if the variable is not equal to 7 using the below.
If(varQuantity <> 7, true, false)
Output:
true
Power Apps IF Function Boolean Examples
Next, I will show you how to work with the Power Apps if function Boolean examples. Such as:
Boolean Value Equals true
Input:
Set(varProducts, true)
Code:
You can check if the variable equals true using the below.
If(varProducts, true, false)
Output:
true
Boolean Value Equals false
Input:
Set(varProducts, false)
Code:
You can check if the variable equals false using the below.
If(varProducts, true, false)
Output:
true
Power Apps IF Function Date Examples
Similarly, if you want to work with the Power Apps date using the if function, follow the examples below. Such as:
IF Date Value Equals Today’s Date or Current Date
Input:
Set(varPurchaseDate, Today())
Code:
You can check if the variable equals today’s date or not using the below.
If(varPurchaseDate=Today(), true, false)
Output:
true
IF Date Value Equals Specific Date
Input:
Set(varPurchaseDate, Date(2024,4,30)
Code:
You can check if the variable equals April 30th, 2024, using the below.
If(varPurchaseDate=Date(2024,4,30), true, false)
Output:
true
IF Date Value is Between Two dates
Input:
Set(varPurchaseDate, Date(2024,4,30)
Code:
You can check if the variable is between April 1st, 2024, and April 30th, 2024 using the below.
If(
varPurchaseDate >= Date(2024, 4, 1)
And varLastSoldDate <= Date(2024, 4, 30),
true,
false
)
Output:
true
Power Apps IF Function Choice Column Examples
Let’s see how to work with the SharePoint choice column with the Power Apps IF() function with a simple example.
IF Choice Column Value Equals
Input: (Product Details)
ID | Product Name | Manufacturer |
1 | Laptop | Apple |
2 | Mobile | Sony |
3 | Air Conditioner | Samsung |
4 | Watch | Apple |
5 | Mouse | Samsung |
Suppose you want to get the last row of the SharePoint list choice field [Manufacturer]; follow the code below.
Set(varProduct, LookUp('Product Details',ID=5))
Code:
You can check if the Manufacturer of the variable equals “Samsung” using the below.
If(varProduct.Manufacturer.Value="Samsung", true, false)
Output:
true
Power Apps IF Function Person Column Examples
In the same way, you can also work with the Power Apps if function person column examples. Such as:
IF Person Column Equals Current User
Input: (Employee Task List)
ID | Task Name | Assigned To |
1 | Create a SharePoint Site | Lynee |
2 | Build Power Apps Application | Johanna Lorenz |
3 | Create Instant Clod Flow | PattiF |
4 | Add IF Conditions on Power Apps | Marium |
5 | Add Button Control in Power Apps | Henrietta Muller |
Follow the code below to get the first row in the Employee Task list using the Person field.
Set(varEmployeeTasks, LookUp('Employee Task List',ID=1))
Code:
Assuming the current user is Lynee, check if the Assigned To of varEmployeeTasks equals the current user
If(varEmployeeTasks.Assigned To.Email = User().Email, true, false)
Output:
true
IF Person Column Equals User Email
Input:
Follow the code below to get the second row in the Employee Task list using the Person field.
Set(varEmployeeTasks, LookUp('Employee Task List',ID=2))
Code:
You can check if the Assigned To column of varEmployeeTasks has an email equal to “JohannaL@szg52.onmicrosoft.com”
If(varEmployeeTasks.Assigned To.Email = "JohannaL@szg52.onmicrosoft.com")
Output:
true
IF Person Column Equals User Name
Input:
Follow the code below to get the last row in the Employee Task list using the Person field.
Set(varEmployeeTasks, LookUp('Employee Task List',ID=5))
Code:
You can check if the Assigned To column of varEmployeeTasks has a name equal to “Henrietta Muller”
If(varEmployeeTasks.Assigned To.Email = "Henrietta Muller")
Output:
true
Power Apps IF Function Lookup Column Examples
Likewise, we will discuss Power Apps if function lookup column examples. Such as:
IF LookUp Column ID Equals
Input: Product Details -> Destination List
ID | Product Name | Manufacturer |
1 | Laptop | Apple |
2 | Mobile | Sony |
3 | Air Conditioner | Samsung |
4 | Watch | Apple |
5 | Mouse | Samsung |
Manufacturer Details -> Source List
ID | Manufacturer |
1 | Apple |
2 | Sony |
3 | Samsung |
4 | Apple |
5 | Samsung |
Follow the code below to get the second row in the Product details list using the lookup field [Manufacturer].
Set(varProduct, LookUp('Product Details',ID=2))
Code:
You can check if the ID of varProduct equals 2
If('Manufacturer Details'.ID=2,true,false)
Output:
true
IF LookUp Column Value Equals
Input:
If you want to get the last row in the Product details list using the lookup field [Manufacturer], follow the code below.
Set(varProduct, LookUp('Product Details',ID=5))
Code:
You can check if the Product Name of varProduct equals “Mouse”
If(Manufacturer.Value="Mouse",true,false)
Output:
true
Power Apps IF Statement OR
Input: (Product Details)
ID | Product Name | Manufacturer | Is Available |
1 | Laptop | Apple | Yes |
2 | Mobile | Sony | Yes |
3 | Air Conditioner | Samsung | No |
4 | Watch | Apple | Yes |
5 | Mouse | Samsung | No |
Suppose you want to get the 3rd row in the Product details list using the Text column [Product Name] and the Yes/No column [Is Available]; you can use the code below.
Set(varProductAvailability, LookUp('Product Details', ID=3))
Code:
You can check if varProductAvailability has a Product Name equal to “Air Conditioner” Or an Is Availability column equal to No
If(
varProductAvailability.Title="
Air Conditioner"
Or varProductAvailability.Is Available,
true,
false
)
Output:
true
Power Apps IF Statement AND
Input:
Suppose you want to get the 5th row in the Product details list using the Text column [Product Name] and the Yes/No column [Is Available]; you can use the code below.
Set(varProductAvailability, LookUp('Product Details', ID=5))
Code:
You can check if varProductAvailability has a Product Name not equal to “Mobile”
If(
varProductAvailability.Title="
Mouse"
And varProductAvailability.Is Available,
true,
false
)
Output:
true
Power Apps IF Statement NOT
Input:
Suppose you want to get the 1st row in the Product details list using the Text column [Product Name] and the Yes/No column [Is Available]; you can use the code below.
Set(varProductAvailability, LookUp('Product Details', ID=1))
Code:
You can check if varProductAvailability has a Product Name equal to “Mouse” And an Is Availability column equal to No Or the Product Name column is equal to “Air Conditioner”
If(Not(varProductAvailability="Mobile"), true, false)
Output:
true
Power Apps IF Statement Multiple Logical Operators
In the last section, I will explain how to work with Power Apps if statements with multiple logical operators. To do so, follow the below steps.
Input:
Suppose you want to get the 3rd row in the Product details list using the Text column [Product Name] and the Yes/No column [Is Available]; you can use the code below.
Set(varProductAvailability, LookUp('Product Details', ID=3))
Code:
You can check if varProductAvailability has a Product Name equal to “Watch” And an Is Availability column equal to No
If(
(
varProductAvailability.Title="Watch"
And varProductAvailability.Is Available="No"
)
Or varProductAvailability.Title="
Air Conditioner")
,
true,
false
)
Output:
true
Additionally, you may like some more articles:
- Patch Function in Power Apps
- Power Apps AddColumns Function
- Slider in Power Apps
- Power Apps Loading Spinner
- How to Use PowerApps Date and Time Picker
- Update Collection in Power Apps
In this article, I explained what Power Apps if function is, Power App if statement syntax, how to use PowerApps if else condition, Power Apps if statement multiple conditions, PowerApps if multiple actions, and a lot more.
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com
Hello,
Is it possible to have more than 3 if statements?
Example:
If(CONDITION A, RESULT A,
CONDITION B, RESULT B,
CONDITION C, RESULT C,
CONDITION D, RESULT D,
DEFAULT RESULT)
Do you find a solution? I want this also
Yes
OR Nested If
If(DateValue1.SelectedDate condition true–i want this three will act it’s possible
(Notify( “You Can’t Select Future Date”, NotificationType.Error))); —> condition false
Error in “Powerapps if statement with or” section:
Powerapps Or function returns true if all arguments are true.
Should be “Poweraps Or function returns true if *any* of the arguments is true.