Detailed Explanation of if in Power Apps|If Specification, Use of Value Return and Process Implementation

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

For example, if you set such an expression in the label’s Text property,
When the slider value is 25, the string “Result1” is returned.

This is how the If function works, returning values as in Excel.

Process like a program

In contrast, for example, put the variable str in the Text property of the label,

Write an expression like this in the OnChange property of the slider,

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

By the way, with the formula here, once the slider value reaches 25, “Result1” will continue to be displayed.

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

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

Related Articles

コメント

Copied title and URL