Mastering the INT Function in Power Automate

Understanding the INT Function in Power Automate

Power Automate is equipped with a rich library of built-in expression functions designed to transform and manipulate data effectively. Among these, the INT function stands out as a frequently used tool when dealing with numeric values. Its primary role is to convert a number into an integer by truncating the decimal portion, thereby returning only the whole number.

What is the INT Function?

The INT function returns the integer portion of a given number. It essentially strips away any digits after the decimal point.

Syntax

The syntax for the INT function is straightforward:

int(value)

Examples

Why Use the INT Function?

The INT function proves invaluable in several scenarios:

Example 1: Convert Decimal Number

If you have an input number like 25.89 and apply the expression int(25.89), the output will be 25.

Example 2: Convert Dynamic Content

When dealing with dynamic content, such as an 'Amount' field from a trigger, you can use:

int(triggerBody()?['Amount'])

If the 'Amount' contains 150.95, the output will be 150.

Example 3: Calculate Working Hours

Imagine a flow that calculates total hours, resulting in a value like 7.85. By applying the INT function to a variable holding this value:

int(variables('TotalHours'))

The output will be 7. This is particularly useful for reporting whole hours worked.

Example 4: SharePoint Number Processing

When retrieving numeric data from SharePoint columns, like a 'Quantity' column:

int(items('Apply_to_each')?['Quantity'])

This allows you to store or use only integer values for inventory calculations, ensuring accuracy in tracking item counts.

Difference Between INT and ROUND

It's crucial to distinguish the INT function from the ROUND function:

The key difference is that INT truncates (cuts off) decimals, while ROUND rounds to the nearest whole number.

Common Use Cases

The INT function finds practical application in various business processes:

Best Practices

To effectively utilize the INT function, consider these best practices:

Benefits of Using INT

Leveraging the INT function offers several advantages:

Conclusion

The INT function is a simple yet powerful expression in Power Automate that effectively converts decimal values into integers. Whether you are working with data from SharePoint, Dataverse, Excel, or external APIs, the INT function provides a reliable method to simplify numeric data, enhance calculation accuracy, and streamline your automated workflows.