web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / What is the difference...
Power Automate
Unanswered

What is the difference between set variable and compose action

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi, 

I cannot understand the difference between the compose action and the set variable. When is it better to use the compose action?

They seems pretty similar to me and I can't understand when to use one rather than the other.

 

could you help me on this topic, please?

thanks and best regards

Categories:
I have the same question (0)
  • Gristy Profile Picture
    2,429 on at

    this podcast discusses it: https://crm.audio/microsoft-flow-compose-vs-variables-outages-and-creating-planner-tasks/

     

    compose does operate faster than using a variable, but sometimes variable can be easier to work with and also do have variety of types, where compose is basically just text input.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Gristy,

    I tried to listen to the podcast but I got 404 not found.

    What I would like to undestard if there is a scenario where I am forced to use the compose action because it is impossible to use the set variable action.

     

    Another doubt I have is why I need to put a compose action after adding a select action to store some data? Is it not possible to reference that by using the output of the select without adding the compose action to the flow?

     

    I'm relatively new and I want to understand the compose action and the best practice for using it in a flow.

     

    Many thanks,

  • Jcook Profile Picture
    7,781 Most Valuable Professional on at

    Hello @Anonymous 

     

    A great example of when to use a Set variable:

    Suppose we initialize a variable called status

     

    Now we have a if condition that will evaluate some data:

    in the if true block:

    We use set variable Status to True

    in the if false block:

    We use set variable Status to False

     

    Now outside the if condition we are sending an email with the status.

    Now we are able to reference the variable regardless of which branch it went in.

    Since set variable Stores the value directly inside the variable.

     

     

    Now if we used a compose for this. There would be 2 separate compose actions. One in the if true block. And one in the if false block. So we wouldn’t not be able to easily reference the status if we stored it inside of the compose.

     

    this is just one example.

  • tonyvisconti Profile Picture
    10 on at

    Does compose have a local scope whereas set has a scope global to the flow?

  • TBail Profile Picture
    22 on at

    Just to give you an answer, even if your question is quite old.

     

    No the scope of both is global to the flow.

     

    From my point of view a variable is an variable. It could be set to different values across the flow. Assume you need a counter variable. within a loop it could be incrementes and initialized to a dynamic value before the loop.

     

    A Compose is more like a constant. If you use compose you store a value in this compose once and you are not able to change the value during the flow.

     

    Hope this helps a little.

  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @Anonymous 

    Here is another way to look at it...

    A compose action is more efficient than a variable.  Many people suggest that you only use a variable when you are required to do so.

    Use a Compose action where the value is going to be set once and only once.  If you are going to need to change the value stored or the value might be set in more than one place, you'll want to use a variable.

    The exception to the rule is that you can use a Compose action inside of a loop and have it set with each loop iteration.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 304

#2
David_MA Profile Picture

David_MA 245 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 243 Most Valuable Professional

Last 30 days Overall leaderboard