In this article, we are going to go through If function examples that can be used in your applications. If is one of the widely used functions in PowerApps. Let’s understand in detail, how to use conditions in your application using some examples.
- If statement is used when we want to execute anything on a conditional basis.
- Using PowerApps If statement, you can evaluate single as well as multiple conditions.
- If there are multiple possibilities against one condition, you can also use PowerApps Switch You can also use If function here, but you will have to repeat the formula for every possible match.
PowerApps If function Syntax
If( Condition, True Execute , Else Execute)
- Condition: This is Required. This is the main statement to evaluate.
- True Execute: This is Required. If the above condition is true, then it will evaluate this statement.
- Else Execute: This is Optional. If the above condition is not true, then it will evaluate this statement.
PowerApps If function examples
If (txtWeather.text = “Overcast”,
“We cannot Play”, ”Its good condition to play”)
Explanation: Here, if the Textbox (txtWeather) value is Overcast then the return result is
We cannot Play (True Execute) else the return result is
Its good condition to play (Else Execute).
PowerApps nested If function example
If (txtWeather.text = “Overcast”,
“We cannot Play”, if (txtHumidity.txt > 45 ,
“We cannot Play”, “Its good condition to play”)
)
Explanation: Here, we have used Nested if statement.
- If the first condition doesn’t satisfy then it goes for Else Execute in that we have added another If statement which will have True Execute and Else Execute
PowerApps UpdateIf() with example
Please visit the article to know details about UpdateIf() function.
PowerApps If Statement Contains text
If("ia" in "india", true, false)
Explanation: Here, we are checking if text (india) contains string ia, then return true else return false.
PowerApps Nested If Examples
PowerApps If condition with List
PowerApps If not blank Statement
If( IsBlank(txtWeather.Text) , true, false)
Explanation: Here, we are checking if textbox (txtWeather) is blank, then returns true else return false.
PowerApps Nested If Examples
PowerApps If condition with List
PowerApps If Statement in list
If(
CountRows(
Filter(Countries, Name = "Australia")
) > 0,
true, false
)
Explanation: Here, we are checking if in the List/Table/Collection (Country) there is any country called Australia (No. of rows more than 0), then returns true else returns false.