cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cnapan
Helper I
Helper I

Compose expression is not working, why?

I have a compose in that shape:

if(and(contains(['Animal1'], 'cat'),contains(['Animal2'], 'dog')),'catdog',if(and(contains(['Animal3'], 'fish'),contains(['Animal1'], 'cat')),'fishcat',''))

 

The idea is to compare values in 3 different columns on Sharepoint list. For example, If column Animal1 has value "cat" and column Animal2 has value "dog", then output is "catdog". I am getting Syntax error on that expression, why?

Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
tom_riha
Super User
Super User

Hello @cnapan ,

this expression is invalid because of the square brackets you use in it [ and ]. You have to either use a value inside single quotes, or some dynamic content. Strings inside [ and ] are invalid.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

3 REPLIES 3
tom_riha
Super User
Super User

Hello @cnapan ,

this expression is invalid because of the square brackets you use in it [ and ]. You have to either use a value inside single quotes, or some dynamic content. Strings inside [ and ] are invalid.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

OK @tom_riha it works when I used values in single quotes. Thank you. Now though I would like to create a flow system, that will update the 3rd coumn based on the values in two other. I build something like this:

cnapan_0-1643741756791.png

The compose include the expression you helped me to write. The update Item has just in proper column the output of expression. But that does not work. Value is not updated. I have feeling the flow I build is to simple, something maybe is missing?

 

Hello @cnapan ,

you should use dynamic content from the trigger instead of the fixed strings, the final expression should look something like:

if(and(contains(triggerOutputs()?['body/Amimal1'], 'cat'),contains(triggerOutputs()?['body/Animal2']),'catdog'...


[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Helpful resources

Announcements
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.

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.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (1,851)