“Power Automate editor tells me that “The expression is invalid” but it doesn’t tell me what’s wrong, how can I fix it?”
“The expression is invalid”. That’s all the information you receive when adding an expression to your flow. But why is it invalid? Which part of the expression must be fixed? What are the most common causes of an invalid expression? This post describes the problems I see all the time.
Wrong single quote character
All the expressions use the same separators – a comma between parameters, and single quotes to define parameter values. The single quote must be always a specific character, the one used in the designer:
If you copy the expression from a page that uses a rich text editor, it might show a different one, e.g.
It’s a small difference from the user perspective, but a big difference from Power Automate point of view.
formatDateTime(utcNow(),'yyyy-MM-dd') - OK formatDateTime(utcNow(),‘yyyy-MM-dd’) - NOT OK
Single quotes around expression or dynamic value
The single quotes should be used only if you type in a value as a parameter. If you use dynamic content or another expression in an expression, it must be without the quotes.
formatDateTime(utcNow(),'yyyy-MM-dd') - OK formatDateTime('2021-12-26','yyyy-MM-dd') - OK formatDateTime(outputs('Compose'),'yyyy-MM-dd') - OK formatDateTime('utcNow()','yyyy-MM-dd') - NOT OK (even though the editor will accept it) formatDateTime(2021-12-26,'yyyy-MM-dd') - NOT OK
Too many or too few single quotes
The single quotes must be always in a pair. If there’s a single quote before the value, there must be exactly one after the value too.
Missing or misplaced closing brackets
The same applies also to brackets. Each expression must have an opening and a closing bracket, and they must be at the right place, after all the parameters. If you build a complex expression, e.g. as in the post on extracting previous SP column values, it’s easy to get lost in the brackets. That’s when you should use a good code editor – I personally use Visual Studio Code.
If you enter the expression in the editor, it’ll highlight the corresponding brackets. That helps a lot to identify if you have all the brackets, and if they’re in the right place.
The flow editor whim
The problem I encounter most often myself is the editor whim. When I enter the expression, it’ll state that the expression is invalid. But only on the first try, after one copy/paste it’ll accept the expression as it is. Sometimes it just needs two attempts instead of one.
As you can see, there’re multiple reasons why Power Automate can give you “The expression is invalid” error message. But if you follow the points in this post, you should be able to identify the problem and quickly fix it.