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
Super User


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.

Frequent Visitor

did you get output??

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 (5,148)