How to Use Power Automate div() Function?

In this Power Automate tutorial, I will explain everything about the Power Automate div() function, like an introduction to the div() function in Power Automate, Syntax, and how to use the Power Automate div() Function in a flow with examples.

Microsoft Power Automate div() function is used for division operations on numeric values. It takes two parameters, the numerator and the denominator, and it returns the result of dividing the numerator by the denominator.

Power Automate div() Function

Power Automate div() function returns the result of dividing two numbers. The div() in the Power Automate function performs division calculation by dividing the first and second numbers. If the dividend or divisor has a Float type, the result will be a float type.

Example

Here, I have given inputs like:

  • Total Laptops: 180
  • Number of Groups: 9

Then, the result will be given for Laptops Assigned to Each Group: 20

Output: The result of division will give an integer value.

Power Automate div() function syntax

This is a brief introduction to the Power Automate div() function.

Power Automate div() Function Syntax

The Power Automate div() function syntax will look as shown below:

div(<dividend>, <divisor>)

Example:

div(22, 7)                                                            // output 3

But if the number is float type, then the output is a float type, as shown below:

div(144.6, 6)                                                     // output 24.1

This is all about the Power Automate div() function syntax.

How to Use Power Automate div() Function

Let’s look at an example of using the Power Automate div() function by creating an instant cloud flow that will trigger manually.

Example:

Now, consider the Total Product Cost [Dividend] is 1000 and the No. of Products [Divisor] is 5. I wanted a single product cost.

So, after using the Power Automate div() function, the result will return a value by dividing both numbers.

Then, the result will be Each Product Cost [200].

Power Automate div() Function

To achieve this, follow the steps below.

1. Navigate to https://make.powerautomate.com in your browser to open the Power Automate home page. Click on + Create -> Select the Instant cloud flow -> Enter the flow name and choose the trigger’s flow (Manually trigger the flow).

  • I have added an input ‘Number‘ in this trigger below.
How to use div() function in Power Automate

2. Next, add the ‘Initialize variable’ flow action to create and set the initial value of a variable within your flow. Set all the details like below:

  • Name: Provide the name of the initialized variable.
  • Type: Select the type of variable as an Integer.
  • Value: Provide the value manually.
div() Function Expression Power Automate

3. Add the ‘Compose’ action to provide the expression to get Each Product Cost, as shown below.

div(variables('Total Products Cost'),triggerBody()['number'])

The Power Automate div() expression calculates the result of dividing the value stored in the ‘Total Product Cost‘ variable by the value of the ‘Number’ property from the trigger body.

Power Automate div() Function Expression

4. Now, it’s time to Save and Test. Click on Test and test it Manually -> Inside the Run flow tab, provide the Number of items value, then click Run flow as shown below.

div() function in Power Automate

5. Then expand the compose flow action it will display the output as shown below.

How to use Power Automate div() function

This is how to use the Power Automate div() function expression in an Instant cloud flow.

Power Automate div() function using SharePoint List

Here, I will show how to use div() in Power Automate using the SharePoint list.

NOTE:

If either the dividend or divisor has Float type, the result has Float type.

Example:

For this, I have taken a SharePoint list named Product Inventory with two number columns named Product Quantity and Product Total Price.

This list has various items and a number column, as shown below.

Columns Data Types
Title (renamed as Product Name)Single line of text
Product BrandChoice
Product QuantityNumber
Product Total PriceNumber
Product Cost Per UnitNumber

I wanted to find the product cost per unit by dividing two SharePoint columns, i.e., [Product Total Price] by [Product Quantity].

We can calculate Product Cost Per Unit using the Power Automate div() function. And I need to update that Product Cost Per Unit value.

Power Automate div() function expression format using SharePoint List

To work around this, follow the steps below.

1. Open the Power Automate home page, click + Create -> Select the Automated cloud flow -> Enter the flow name and choose the trigger’s flow (When an item is created or modified).

  • In this trigger, provide the Site Address and List Name.
How to use div() function expression in Power Automate using SharePoint List

2. Add the Initialize variable flow action and set the required fields:

  • Name: Enter the name of a variable.
  • Type: Select the variable type as Float.
  • Value: Here, I have given ‘Product Quantity’ from dynamic content.
Power Automate div() function format using SharePoint List

3. Next, add another ‘Initialize variable’ flow action to initialize the SharePoint list column values.

  • Name: Give a name for the variable.
  • Type: Select the type of variable as Float.
  • Value: Here, I have selected ‘Product Total Price‘ from dynamic content.
How to use div function format in Power Automate using SharePoint List

4. Then add the ‘Compose’ flow action to provide the expression to get the Product Cost per unit.

div(variables('ProductTotalCost'),variables('ProductQuantity'))
Power Automate div() expression using SharePoint List

5. Add the ‘Update item’ flow action to modify or update existing items in the SharePoint list and set all the details.

  • Site Address: Provide the SharePoint site address.
  • List Name: Select the name of the SharePoint List.
  • Id: Here, I have selected ‘ID’ from dynamic content.
  • Product Cost Per Unit: Here, I have given the Outputs of the compose action from dynamic content to update the SharePoint column.
How to use div() expression in Power Automate using SharePoint List

6. Now, it’s time to Save and Test. Click on Test and test it Manually. Then, open the SharePoint list; it will display the output by updating the SharePoint column as shown below.

Power Automate div() expression format using SharePoint List

This is how to use the div() function in Power Automate using SharePoint list column values.

Conclusion

I hope you find this Power Automate tutorial helpful. Here, we will discuss what the div() function means and overview its syntax. Moreover, I have explained how to use the div() function in Power Automate manually.

Also, we saw how to use the div()function in Power Automate using SharePoint List.

Additionally, you may like some more Power Automate tutorials: