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

Community site session details

Session Id : tRi3RjvNGURGpl3b4djanK
Power Automate - General Discussion
Answered

Using Initialize Variable versus Compose to get the output of a function

Like (0) ShareShare
ReportReport
Posted on 15 Apr 2024 21:35:40 by 14

The scenario is a flow triggered by a form submission. The flow adds the form responses to an Excel file in SharePoint and then invokes a script in the file to do some additional processing.

 

Because the anonymous respondents can be located anywhere in the world, I needed to convert the form submission date and time stamp to Eastern Standard Time. Looking online I found the required timezone conversion function, but the example used a Compose action to invoke the function and then used the output from that to set a variable.

 

I don't like adding extra steps in my flows, so instead I used the Initialize Variable action to define a variable to hold the result and in the initial value field for the action I created an expression with the timezone conversion function. In the "Add a Row to an Excel file" action, I used the resulting variable for the corresponding field in the SharePoint Excel file.

 

This works, but I'm wondering if there is some hidden gotcha to this approach?

  • DJ_Jamba Profile Picture
    2,832 Super User 2025 Season 2 on 15 Apr 2024 at 22:08:05
    Re: Using Initialize Variable versus Compose to get the output of a function

    too late pal!
    🤣

  • MisterDon Profile Picture
    14 on 15 Apr 2024 at 22:06:45
    Re: Using Initialize Variable versus Compose to get the output of a function

    @DJ_Jamba- it looks like you headphones are going to give you a sore left ear d(-_-)b <---

  • DJ_Jamba Profile Picture
    2,832 Super User 2025 Season 2 on 15 Apr 2024 at 22:03:21
    Re: Using Initialize Variable versus Compose to get the output of a function

    Cool 😎 Glad it's sorted!
    d(-_-)b

  • MisterDon Profile Picture
    14 on 15 Apr 2024 at 22:01:58
    Re: Using Initialize Variable versus Compose to get the output of a function

    @DJ_Jamba- Nice! I'm marking your first reply as the accepted solution.

  • DJ_Jamba Profile Picture
    2,832 Super User 2025 Season 2 on 15 Apr 2024 at 21:57:12
    Re: Using Initialize Variable versus Compose to get the output of a function

    Spot on or you could use the Convert time zone action

    DJ_Jamba_0-1713218196544.png

    and select that action from dynamic content instead...

  • MisterDon Profile Picture
    14 on 15 Apr 2024 at 21:50:10
    Re: Using Initialize Variable versus Compose to get the output of a function

    @DJ_JambaThanks for the quick and informative response. Makes sense.

     

    So in this case if I use Compose to convert the date/time, then rather than creating a variable, which as you point out isn't really varying, I would find the Compose output under dynamic content when entering the value for the corresponding Excel file column, right?

  • Verified answer
    DJ_Jamba Profile Picture
    2,832 Super User 2025 Season 2 on 15 Apr 2024 at 21:42:09
    Re: Using Initialize Variable versus Compose to get the output of a function

    Hi @MisterDon 

     

    No gotchas. You can use a variable but the example you looked at was correct to use a Compose.

    Constants (values that don't change throughout your flow) - Use Compose

    Variables (values that change throughout your flow) - Use Variables

     

    The flow will assign a variable lock on variables and if you have a lot in your flow, it can slow the flow down. 

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2

Loading complete