cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Setting variable in expression

I have a variable called VarX and I want it to set to "X" if the corresponding SharePoint field is "YES", if the corresponding SharePoint field is "NO", I want to set "X" to either null or "". 

 

How do you do this in an expression? `if(triggerBody()?[SPField] = 'YES','X',"")`  something like that?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi!
This is a very useful reference when dealing with expressions
https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference
Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

4 REPLIES 4
efialttes
Super User
Super User

Hi!
I would try
if(equals(triggerBody()?['SPField']),'YES'),'X','')

Please note two single quotes after the last comma
Hope this helps


Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



v-alzhan-msft
Community Support
Community Support

Hi @Anonymous ,

 

What is the type of the SPField? Is it a single line of text column, or Yes/No type column, or a Choice type column?

Could you please share a screenshot of the configuration of your flow?

1.png

If the SPField is single line of text column, the Expression should as below the same as @efialttes  provided:

if(equal(triggerBody()?['SPField'],'YES'),'X','')

 

If the SPField is Yes/No type column, the expression should as below:

if(equal(triggerBody()?['SPField'],true),'X','')

 

If the SPField is choice type column, the expression should as below:

if(equal(triggerBody()?['SPField']?['Value'],'YES'),'X','')

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi!
This is a very useful reference when dealing with expressions
https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference
Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



v-alzhan-msft
Community Support
Community Support

Hi @Anonymous ,

 

Have your problem been solved?  If yes, please go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,606)