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 Apps / [HELP] FOR LOOP INCREM...
Power Apps
Answered

[HELP] FOR LOOP INCREMENT VARIABLE

(0) ShareShare
ReportReport
Posted on by 99

Hello Everyone! 

Good day!

I want to increment inside ForAll. My expected output is to get value of ID: 2 AND 4. because the counter value is 2.

How to correct this? Thanks in advance

Clear(newCollection);
Clear(Counter);
Set(varID, 0);
Set(varCounter, 2);
Set(varCounter2, 1);
ClearCollect(
 colTestItems,
 {ID: 1, Value: "13.54"},
 {ID: 2, Value: "15.54"},
 {ID: 3, Value: "14.54"},
 {ID: 4, Value: "16.54"},
 {ID: 5, Value: "18.54"},
 {ID: 6, Value: "12.54"}
);

ForAll(
 FirstN(colTestItems, 2),
 Collect(Counter, 2); 
 Collect(newCollection, {Value: LookUp(colTestItems, ID=varID+CountRows(Counter)).Value });
)

 

Categories:
I have the same question (0)
  • Verified answer
    Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @Houji ,

     

    Are you trying to achieve this?

    ForAll(
     Sequence(2, 2, 2),
     With
     (
     {currentIndex: Value },
     Collect
     (
     newCollection,
     {
     Value: LookUp(colTestItems, ID = currentIndex, ThisRecord)
     }
     )
     )
    )

     

    Hope this helps

  • Houji Profile Picture
    99 on at

    Hi @Ethan_R , 

    This is way correct.

    But I want to have this

    Houji_1-1684195697472.png

     

    rather than this. This is the result of your code above

    Houji_0-1684195673651.png

     

  • Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @Houji ,

     

    ThisRecord gives complete record as collection.
    You can use 'ThisRecord.Value' or any column name after '.' operator. 

     

    Hope that helps

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 516

#2
WarrenBelz Profile Picture

WarrenBelz 428 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 292

Last 30 days Overall leaderboard