Exercise - Creating a manual flow and using expressions

Completed

Let's say you need to find out how much it would cost to carpet a room based on its square footage. In this exercise, you create a manual flow that uses your input to do those calculations.

  1. Sign into Power Automate.

  2. In the Copilot box, type Create an instant flow with two compose actions. Then select Generate.

    Screenshot of select manually trigger a flow.

  3. Copilot automatically generates a flow. Review the flow to make sure it has a Manually trigger a flow trigger and two Compose actions.

  4. Select the Manually trigger a flow trigger. The properties pane expands on the left. Select Add an input.

  5. Choose Number and name it Square Footage.

  6. Select Add an input and choose Number again and name it Cost.

  7. Select the first Compose action.

  8. Select the Inputs box and a blue rectangle with a lightning bolt on top and fx on the bottom appears. Select the fx to bring up the expressions bar.

  9. Select the Function tab and type in mul(. Power Automate knows that you're using the multiply expression and automatically add a ) at the end for you.

  10. With your cursor still between the two parentheses in the expression field, select the Dynamic content tab.

  11. Select Square Footage from the dynamic content.

    Tip

    If you don't see Square Footage, select See More next to the action's title in the Dynamic Content box to show more property options.

  12. Next add a comma (,) and choose Cost in the dynamic content.

  13. The complete expression should be:

    mul(triggerBody()?['number'],triggerBody()?['number_1'])
    
  14. Select Add to add the expression into the Compose step.

    Screenshot of add the expression into the Compose step.

  15. You know your expression is correct if it's added into the Compose step and looks like:

    Screenshot of correct expression in Compose step.

    This compose step is now doing the math of calculating the square footage of the area multiplied by the cost per square foot based upon inputs you provide. However, we still need to convert the final result to currency to get the correct answer.

  16. Select the Inputs box for the second Compose action and select the blue fx to open the Functions box.

  17. Type in formatNumber(.

  18. With your cursor in place, select the Dynamic content tab and choose Outputs from the previous Compose step.

  19. Next finish the expression with , 'C2'.

    The C formats the number as currency, with the 2 representing how many decimal places. Refer to Standard numeric format strings for more number formats.

  20. The complete expression is:

    formatNumber(outputs('Compose1'), 'C2')
    

    Important

    In this example, Copilot named the first Compose in the flow as Compose1. In your flow, copilot may have named the first Compose without the '1'. If this is the case, remove the 1 in Compose1 in the formula above.

  21. Select Add to add this expression in the Compose2 step.

    Screenshot of add expression to Compose 2 step.

    Now after our flow is triggered, it first multiplies the two numbers, then converts the result into the correct currency format. This gives you a quick way to get the cost associated with carpeting a room.

  22. Your complete flow looks like this:

    Screenshot of completed flow with Manually trigger a flow, Compose1, and Compose 2.

  23. In the top-right corner, select the Save button, then select Test.

  24. Choose Manually and then select Test.

  25. Enter the two number inputs, Square Footage and Cost, and then select Run flow at the bottom.

  26. The page reloads and you see green check marks next to each step of your flow.

  27. Selecting each step expands the details showing you the inputs and outputs of each step.

  28. Selecting the first Compose shows the multiplied value of the two numbers you entered, while selecting the second Compose shows the currency format of that multiplied value.

Let's recap what we did.

Manually trigger a flow - Allows us to press a button to trigger a flow and provide inputs. In this case our two inputs are Square Footage and Cost, which we're using to find out the total price to carpet a room.

Compose - Used to write expressions using the data from elsewhere in the flow. In this case, we first multiplied the two inputs from the trigger. This gave us the correct number, but we still needed to convert it to currency. We then used another compose action to format the multiplied result into currency, giving us the answer to how much it would cost to carpet a room.