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

How to use a variable inside a Power Automate expression

I'm trying to work with the setProperty function in order to edit a JSON body during the execution of a flow, here is the expression:

setProperty(X, 'Y','bla bla 123456789' )


  • X is the json
  • Y the property i want to modify
  • 'bla bla 123456789' is the value

My question is: how can I replace '123456789' by a variable('ID') inside it, if I do the following thing

setProperty(X, 'Y','bla bla variables('ID')' )

It will take exactly what is written "variable('ID') and not the value of this variable !

any help ?

Resident Rockstar
Resident Rockstar



The easiest way is whilst writing your expression. Click Dynamic Content and then Select your Variable and it will insert it in the right format for you.


The outcome is something like: 

looks like you are missing the s in your example.
Super User III
Super User III


While you are in the expression at the place where you want to reference the variable, simply click on the Dynamic properties tab and select your variable.  Then, click on the expression tab again.  Your variablke should be inserted into the expression.

If I have not answered your question, please let me know.


If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.




I know that, the problem is not there !


here is my real expression : 


setProperty(body('Get_Flow')['properties']['definition']['triggers']['When_an_item_is_created_or_modified']['inputs'], 'path','/datasets/@{encodeURIComponent(encodeURIComponent(''''))}/tables/@{encodeURIComponent(encodeURIComponent(''3939098e-a076-48e8-b020-b0df1589b327''))}/onupdateditems' )


Can you see that id :  3939098e-a076-48e8-b020-b0df1589b327, i need to replace it by variables('ID'), if i do like you said it will exactly write 'variables('ID')' while I need it value

Yes if you enclose it in ' it will treat it as a string rather than putting the dynamic content in. if you need the ' around you need to first build it in a compose or use concat expression.

Helpful resources

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group


Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (43,760)