Conversion Functions in Power Automate
π Conversion Functions in Power Automate
Conversion functions in Power Automate are essential when working with different data types. Whether you’re converting strings to numbers, dates to text, or parsing JSON into usable values, these functions ensure your flow interprets data correctly.
By mastering conversion functions in Power Automate, you can streamline processes, prevent errors, and ensure compatibility across services like SharePoint, Dataverse, Excel, and external APIs.
π Why Use Conversion Functions in Power Automate?
Youβll need conversion functions when:
- Data types from connectors donβt match required formats
- You need to transform inputs before using them
- Converting numeric strings into actual numbers
- Parsing boolean, datetime, or currency fields
- Formatting data for user-facing emails, approvals, or messages
πΌ Real-World Use Cases for Conversion Functions
Use Case | Description |
---|---|
Convert string "100" to number for math operations |
Use int() or float() |
Format a timestamp to MM/dd/yyyy |
Use formatDateTime() |
Convert "True" to actual boolean |
Use bool() |
Parse a currency field and round | Use float() + formatNumber() |
Convert object to JSON string | Use string() on JSON object |
π§ Common Conversion Functions in Power Automate
Hereβs a detailed list of the most useful conversion functions in Power Automate, including syntax and examples:
Function | Purpose | Syntax | Example | Output |
---|---|---|---|---|
int() |
Converts value to integer | int('123') |
123 |
|
float() |
Converts to decimal number | float('123.45') |
123.45 |
|
string() |
Converts value to string | string(123) |
'123' |
|
bool() |
Converts to true/false | bool('true') |
true |
|
array() |
Converts comma-separated string to array | array('a,b,c') |
['a','b','c'] |
|
json() |
Parses string to object | json('{"name":"Alice"}') |
Object | |
formatNumber() |
Formats number as string | formatNumber(1000, '##,###') |
'1,000' |
|
formatDateTime() |
Formats datetime string | formatDateTime(utcNow(), 'yyyy-MM-dd') |
'2025-08-07' |
|
ticks() |
Converts datetime to ticks | ticks(utcNow()) |
Long integer | |
fromBase64() |
Decodes base64 to binary | fromBase64(base64String) |
Binary | |
base64() |
Encodes string to base64 | base64('Power') |
Encoded string |
π§ͺ Practical Examples of Conversion Functions
1. Convert Numeric Input from Text Field
int(triggerBody()?['Score'])
Use Case: Allows comparison or mathematical operations on form inputs.
2. Format a Currency Field for Email
formatNumber(float(triggerBody()?['Total']), 'C2')
Use Case: Sends a nicely formatted currency in an email like $1,000.00
.
3. Convert Boolean String to Actual Boolean
bool(triggerBody()?['Confirmed'])
Use Case: Drives conditional logic like approvals or toggles.
4. Convert and Parse JSON Response
json(outputs('HTTP_Response')?['body'])
Use Case: Extracts nested fields for further use in the flow.
5. Create an Array from a String
split('One,Two,Three', ',')
Note: Use split()
instead of array()
for better control.
β Best Practices for Using Conversion Functions in Power Automate
- β
Always validate data before converting (e.g., use
empty()
orcoalesce()
) - β
Use
float()
instead ofint()
when dealing with decimal values - β
Wrap
json()
calls intry/catch
logic or validate inputs to avoid runtime errors - β Avoid chaining too many conversions in one expressionβuse Compose for readability
- β
Use
formatDateTime()
andformatNumber()
for user-facing outputs
β οΈ Common Pitfalls with Conversion Functions
Problem | Cause | Fix |
---|---|---|
Flow fails on null input | Applying int() or float() on null |
Use coalesce() to provide fallback |
Incorrect string formatting | Using int() on "123.45" |
Use float() instead |
Date parsing errors | Using wrong format | Use formatDateTime() with correct pattern |
JSON errors | Parsing invalid JSON string | Use try/catch logic or test with isJSON() custom logic |
π Summary: When to Use Conversion Functions in Power Automate
Use conversion functions in Power Automate when:
- Working across connectors with mismatched data types
- Formatting numbers and dates for user communication
- Validating and transforming API responses
- Ensuring type consistency for expressions and conditions
- Parsing complex structures like JSON and arrays