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 / Problem with variable ...
Power Automate
Answered

Problem with variable initialized in foreach loop

(0) ShareShare
ReportReport
Posted on by 691

Hello,
When I initialize the variable "Montant_Actuel" it automatically goes into a foreach loop, and then when I save my WorkFlow it gives me an error telling me that a variable cannot be initialized in a foreach loop.

The value I give to my variable is a value that comes from one of my SharePoint lists.
How do I remove my variable from the foreach loop?

s44_0-1640857824746.png

 

Thanks in advance !

Categories:
I have the same question (0)
  • Verified answer
    vikulkar Profile Picture
    Microsoft Employee on at

    Hi @s44 ,

    You would want to check what type of column is "Montant_Actuel" in the SP list?

    If it is an array and something that can hold multiple values, the PowerAutomate flow automatically generates an ApplyToEach loop. In which case you will have to initialize your variable as an array.

     

    OR 

     

    If you know the column always holds a single value then you can "initialize variable" before the loop and then use a "Set variable" action inside the loop as shown below.

     

    Community09.png

    Note: You can only use set variable inside a loop and not initialize inside a loop.

     

    Thanks and Regards,

    Vikas K

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
David_MA Profile Picture

David_MA 251 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 239

#3
Expiscornovus Profile Picture

Expiscornovus 220 Most Valuable Professional

Last 30 days Overall leaderboard