Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

How do you find where the error is in an expression?

I have a complex expression in a Compose action. When I run the flow I get the following error:


InvalidTemplate. Unable to process template language expressions in action 'Status' inputs at line '1' and column '18164': 'The template language function 'if' expects three parameter: the condition to test as the first parameter, the value to return if the condition is true as the second parameter, and the value to return if the condition is false as the third parameter. The function was invoked with '1' parameter(s). 


I have gone over the expression and I cannot find where the issue is! I am sure it is a misplaced comma or bracket, but I cannot find it.


The expression is:

if(equals(outputs('Progress'),'Completed'),if(greater(formatDateTime( last(body('Filter_completed_tasks'))?['Completed_x0020_Date'] ), formatDateTime( last(body('Filter_completed_tasks'))?['Due_x0020_date'] )), 'Delivered late''Delivered on-time'), if(empty(body('Filter_not_started_tasks')), 'Error', if(greater(utcNow(), formatDateTime( last(body('Filter_not_started_tasks'))?['Due_x0020_date'] )), 'Behind schedule','On-target')))


The error message helpfully gives the location of the issue (line 1, column 18164), but I have no idea how to find that location!


Can anyone give me advice on how to debug this?

Community Champion
Community Champion

Use different variables and assign individual expression to variables...


Use Switch case if possible

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (2,512)