The left() function in Power Automate returns a specified number of characters from the beginning (left side) of a string. Its syntax is left('text', number), and it is used inside expressions, for example left('Power Automate', 5) returns 'Power'.
What the left() function does
Power Automate expressions include a set of string functions that let you manipulate text values in your flows. The left() function extracts a substring starting from the first character (index 0) and moving right. It takes exactly two arguments:
- String – the text you want to take characters from. This can be a literal string in single quotes, a variable, or an expression that returns a string.
- Length – a positive integer specifying how many characters to return.
For example, if you have a variable named FullName with the value 'John Smith', the expression left(variables('FullName'), 4) returns 'John'. The function counts each character, including spaces and punctuation, so left('Hello World', 5) returns 'Hello' (the space is at index 5, so it is not included).
Where to use left() in a flow
You can use left() in any action that accepts an expression. The most common places are:
- Compose action – add an expression directly in the input field.
- Condition control – compare a truncated string to a value.
- Apply to each – inside the loop, reference the current item.
- Send an email or create a record – build a subject or field value from a longer string.
To insert the function, click in the field where you want the result, then choose Expression from the dynamic content panel. Type left( and then select the source string from the dynamic content list or type a literal in single quotes. After a comma, type the number of characters. Close the parenthesis and click OK.
How to choose the number of characters
The length argument must be a non-negative integer. If you use a decimal, Power Automate rounds it to the nearest whole number. If you use a negative number or a value larger than the string length, the behavior differs:
- If the length is 0, the function returns an empty string
''. - If the length is greater than the string length, it returns the entire string, not an error.
- If the length is negative, the expression fails with an error in the run history.
For dynamic lengths, you can nest another function. For example, to get the first half of a string, use left('abcdef', div(length('abcdef'), 2)) which returns 'abc' (length 6 divided by 2 equals 3). The length() function returns the total character count.
Common problems and errors
The most frequent issue is forgetting the single quotes around a literal string. In Power Automate expressions, text must be wrapped in single quotes, not double quotes. Writing left("hello", 2) causes an error because double quotes are used for other purposes (like JSON). Another common mistake is using the function on a field that is not a string – for example, a number or a boolean. Power Automate will attempt to convert the value to a string, but if the conversion fails, the expression returns an error. To be safe, wrap the value with the string() function first: left(string(triggerBody()?['numberField']), 3).
Also note that left() is case-sensitive and does not trim spaces. If your string has leading spaces, they count as characters. Use trim() before left() if you want to ignore whitespace: left(trim(variables('Text')), 10).
Comparing left() with substring() and right()
Power Automate has three related functions for extracting parts of a string:
left()– takes characters from the start.right()– takes characters from the end, e.g.,right('Power Automate', 6)returns'tomate'.substring()– takes characters starting at a given index for a given length, e.g.,substring('Power Automate', 6, 4)returns'Auto'.
Use left() when you always want the beginning of the string. Use substring() when you need to start from a specific position, such as the third character. Use right() for suffixes like file extensions. For example, to get the first letter of a name, left(variables('Name'), 1) is simpler than substring().
Real-world examples
Here are three practical scenarios where left() solves a common problem:
- Extract area code from a phone number – If a phone number is stored as
'(555) 123-4567', the expressionleft(variables('Phone'), 3)returns'(55'because it counts the parenthesis. To get just the digits, first remove non-numeric characters with a more complex expression, or simply usesubstring()with the index of the first digit. - Generate a short code from a long ID – For a 32-character GUID like
'123e4567-e89b-12d3-a456-426614174000',left(variables('GUID'), 8)returns'123e4567', which can be used as a reference label. - Validate a prefix in a condition – To check if a file name starts with ‘Draft’, use a condition with the expression
left(triggerBody()?['fileName'], 5)equals'Draft'.
Performance and limitations
The left() function is fast and has no special performance concerns. It works on strings up to the maximum size allowed by Power Automate (currently around 100 MB for a single string, though practical limits are much lower). The function is available in all Power Automate plans, including the free Microsoft 365 license that includes Power Automate for Office 365. There is no additional cost for using string functions. One limitation: left() does not work on arrays or objects directly. If you pass an array, Power Automate converts it to a JSON string, which may produce unexpected results. Always convert to a string first if you are unsure.
Frequently Asked Questions
Can I use left() on a number?
Yes, but only after converting the number to a string. Power Automate will implicitly convert a number when you use it in an expression, but it is safer to write left(string(variables('Number')), 2) to avoid errors. For example, left(string(12345), 2) returns '12'.
What is the difference between left() and take()?
Power Automate does not have a take() function. That function exists in Power Apps and some other Microsoft products. In Power Automate, use left() for strings and take() is not available. For arrays, you would use take() in Power Apps, but in Power Automate you can use the first() function or slice() for arrays.
How do I get the last 3 characters instead of the first 3?
Use the right() function: right('Power Automate', 3) returns 'ate'. Alternatively, you can combine length() and substring(): substring('Power Automate', sub(length('Power Automate'), 3), 3).
Why does my left() expression return an empty string?
This usually happens when the length argument is 0, or when the source string is empty. Check that the variable or field you are referencing has a value. Also, if you are using a dynamic content item that is not available at runtime (for example, a field from a trigger that did not fire), the expression may evaluate to an empty string.
Can left() handle Unicode characters like emojis?
Yes, but be aware that some emojis are represented by multiple code points. The function counts characters, not bytes, so an emoji like 😀 may count as 2 characters in some cases. If you need to handle emojis precisely, consider using a different approach, but for most text, left() works fine.
Related
- 6 Digit Random Number: How to Generate One
- Shortcut Command for Cut: Ctrl+X Explained
- Best Data Entry Sites: Top Picks for Real Work
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Formula for Mileage Calculation: How ToThe core Excel formula for mileage calculation is simple: =EndOdometer - StartOdometer for distance, or =MilesDriven * RatePerMile…
- LEFT Function in Excel for Dates: How to Extract PartsTo use LEFT with a date in Excel, first turn the date into text in the format you…
- FV Calculation in Excel: Formula & ExamplesThe FV (Future Value) function in Excel calculates the future value of an investment based on a constant…
- Multiple Results VLOOKUP: 5 Ways to Return Every MatchThe direct answer: VLOOKUP alone returns only the first match, so to get multiple results you must combine…
- Excel INDEX MATCH Duplicates: How to Handle ThemYes, Excel’s INDEX MATCH can return duplicate values, but the way it handles them depends on your formula…
- Excel FILTER Formula for Multiple CriteriaTo filter rows in Excel by multiple criteria, use FILTER with a condition for each test: multiply the…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.