Skip to main content

Notifications

Community site session details

Community site session details

Session Id : TTxsrPgfwCWwUpMAUgo004
Power Apps - Building Power Apps
Answered

Two For Loops with ForAll

Like (0) ShareShare
ReportReport
Posted on 11 Apr 2022 12:31:40 by 7

Hey guys,

 

I have the following problem. I want to create a table that looks like the following. My problem is, that number of parts is based on a form value (let's say the user can choose between 1 and 5 parts per order). So normally I would use two for loops, the first one loops over the number of stations (in my production 1 to 6) and the second loop over the number of parts the customer selected.

 

OrderStationPart
HTW-001711
HTW-001721
HTW-001731
HTW-001741
HTW-001751
HTW-001761
HTW-001712
HTW-001722
HTW-001732
HTW-001742
HTW-001752
HTW-001762

 

ForAll(
Sequence(CountRows(Tabelle5)) /* The number of stations I have in my production */ ;
ForAll(
Sequence(DataCardValue40.SelectedText.Value) /* The number of parts the customer ordered */;
Patch(
Tabelle1;
Defaults(Tabelle1);
{
Auftrag: Auftragsnummer; /* Order Number */
Station: zaehler /*My Variable for the iterator, which isn't working/;
Teil: Value /* The iterator which is working fine, for the second sequence*/;
Status: "Nicht gestartet"
};;
)
)
)

 

 

I tried using a iterator, unfortunately you can't update context within ForAll. Any suggetstions how I could solve that? 

  • dnhrtmn Profile Picture
    7 on 11 Apr 2022 at 12:56:33
    Re: Two For Loops with ForAll

    Oh gosh, thank you so much!

  • Verified answer
    Adrian_Celis Profile Picture
    1,652 Super User 2025 Season 1 on 11 Apr 2022 at 12:49:42
    Re: Two For Loops with ForAll

    Hi @dnhrtmn 

     

    You can us an alias using AS to name your ForAll loop so that PowerApps know which loop you are referring to.

    Example:

    ForAll(
    Sequence(CountRows(Tabelle5)) As Loop1 /* The number of stations I have in my production */ ;
    ForAll(
    Sequence(DataCardValue40.SelectedText.Value) As Loop2 /* The number of parts the customer ordered */;
    Patch(
    Tabelle1;
    Defaults(Tabelle1);
    {
    Auftrag: Auftragsnummer; /* Order Number */
    Station: Loop1.Value
    Teil: Loop2.Value /* The iterator which is working fine, for the second sequence*/;
    Status: "Nicht gestartet"
    };;
    )
    )
    )

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 89 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 54

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 42 Super User 2025 Season 1

Overall leaderboard
Loading started