Power Automate Sub Function Explained

Power Automate Sub Function

The Power Automate Sub function lets you subtract two numbers.

Its counterpart is the add function that lets you compute the sum of two numbers.

In this article, I’ll introduce you to the sub function and will provide a step-by-step guide on how to use the function in a Microsoft flow.

Power Automate Sub Function

Retrieve the outcome of subtracting the second number from the first number.

Syntax

sub(<minuend>, <subtrahend>)

Input parameters

  • minuend (mandatory): The number from which the subtrahend will be subtracted.
  • subtrahend (mandatory): The number which will be subtracted from the minuend.

Return value

  • Returns the difference between the first and second numbers.

Power Automate Sub Example

sub(3,1)
=> 2  // 3-1=2

// sample with use of a variable

sub(variables('myNumber'),1)

How To Use The Power Automate Sub Function

Follow the steps to use the Power Automate sub function in a flow.

  1. Create a new flow with trigger ‘Manually trigger a flow’

    Power Automate Sub Function new flow

    New flow

  2. Add a new step by clicking on ‘+ New step’

    Power Automate Sub Function new step

    Add a new step

  3. Search for ‘initialize’ and click on ‘Initialize variable’

    Power Automate Sub Function add initialize variable step

    Add Initialize variable action

  4. Setup Initialize variable: 1) Provide a name, 2) select type Integer, 3) Set value to 3

    Power Automate Sub Function setup init var

    Setup variable

  5. Add a compose by searching for ‘compose’ and clicking on ‘Compose’

    Power Automate Sub Function add compose step

    Add Compose action

  6. Setup compose action: 1) click into Inputs (popup appears), 2) click on ‘Expressions’, 3) set expression to ‘sub(variables(‘myNumber’),1)’, 4) click on ‘OK’

    Power Automate Sub

    Setup add expression in Power Automate

  7. Do a test run

    Power Automate Sub Function test run

    Result test run – Power Automate Sub function example

Leave a Comment

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