I have looked into the use of if in Power Apps in detail and note the results.
Return value or process
The if function in Power Apps has the following two functions.
- Return values as in Excel
- Process like a program
Return values
This is how the If function works, returning values as in Excel.
Process like a program
When the slider value changes to 25, the variable str is assigned the string “Result1” and the label is displayed as Result1.
This is how the If function works, processing like a program
Thus, the If in Power Apps combines the function of returning a value with the function of processing.
The If that returns the result is used at the point where the value is entered, such as the Text or Fill property, and the If that performs the processing is used in the property that is called when an event occurs, such as OnChange or OnSelect.
Power Apps if Specifications
“None of the conditions are true, none of the matches are found, and if you do not specify a default result, it returns blank.”
The following expression returns true as a result.
IsBlank(if(false,false))
*I don’t think anyone will do this.
It is always a good idea to set the default result of if to prevent unexpected behavior.
How to use the if function
Now we will show an example of the actual use of if.
if else
What we want to do
If(Condition) Processing 1 else Default process
In Power Apps, the formula is as follows
If(Condition, Processing1, Default process)
if elseif else
What we want to do
If(Condition1) Processing1 else if(Condition2) Processing2 else Default process
In Power Apps, the formula is as follows
If(Condition1, Processing1, Condition2, Processing2, Default process)
*If you put a condition in the third argument, it becomes an else if.
If default processing is omitted, a blank is returned if it is an if function that returns a result, or nothing is done if it is an if function that performs processing.
And
What we want to do
If(Condition1 && Condition2) Processing1 else Default process
In Power Apps, the formula is as follows
If(And(Condition1, Condition2), Processing1, Default process)
or
If(Condition1 && Condition2, Processing1, Default process)
Or
What we want to do
If(Condition1 || Condition2) Processing1 else Default process
In Power Apps, the formula is as follows
If(Or(Condition1, Condition2), Processing1, Default process)
or
If(Condition1 || Condition2, Processing1, Default process)
Any number of conditions within And and Or can be added by separating them with
コメント