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

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (74,326)