Describe use cases for formulas – Demonstrate the capabilities of Power Apps

Describe use cases for formulas

Formulas in Power Apps function in much the same way as formulas in Microsoft Excel. Developers can use formulas to perform operations on cell contents and to modify the functionality of controls, such as buttons, drop-down lists, and combo boxes.

Performing operations with formulas

For example, just as people can use the sum function in Excel to total a column of cells, a developer can use the sum function in a Power App to add the numerical values in multiple text boxes together. In Figure 4-15, the sample app shown has three text input controls called TextInput1, TextInput2, and TextInput3 with numerical text in them. The fourth element is a label control with the following multifunction formula in it:

FIGURE 4-15 The Power Apps workspace containing a sample canvas app with a Sum formula

Click here to view code image

Sum(Value(TextInput1.Text),Value(TextInput2.Text),Value(TextInput3.Text))

In this formula, the Value function converts the text in each of the first three controls into a value that can be manipulated. The Sum function then adds the three values together into a total that appears in the Label1 control. The developer can also elaborate on the formula by adding other functions, such as the If function in the following example:

Click here to view code image

If(Sum(Value(TextInput1.Text),Value(TextInput2.Text),Value(TextInput3.Text)) >=65,
“Pass”,”Fail”)

This formula uses the If function to evaluate the sum, as in the case of a teacher calculating a quiz grade. If the value arrived at by the Sum function is greater than or equal to 65, then the Label1 control displays Pass, as shown in Figure 4-16; if the sum is less than 65, Fail appears.

FIGURE 4-16 The Power Apps workspace containing a sample canvas app with a formula using the If function to evaluate a sum

Leave a Reply

Your email address will not be published. Required fields are marked *