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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Problem with variable ...
Power Automate
Unanswered

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard