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 / Add numbers with seque...
Power Apps
Answered

Add numbers with sequence in collection

(0) ShareShare
ReportReport
Posted on by

Hi Experts!

I have a collection like this : 

 

Kepcla_0-1696962792422.png

 

And need to achieve this :

Kepcla_1-1696962837217.png

 

I don´t know how to create the number from to columns. I{m trying to use "sequence function" but not working. ...any ideas?

Appreciate a lot your help!!

Categories:
I have the same question (0)
  • Marshal_Jerome Profile Picture
    88 on at

    Hi @Kepcla 

     

    The below example inserts data into a collection while pressing a button. that collection will be used as a source for the gallery. if you want to generate without pressing button modify the code according but below code can be used as base logic.

     

     

     

    1. Add a button and place this code at OnSelect trigger.

         

    Collect(RangeValues,
    {
    RangeStart: 0,
    RangeEnd: 0,
    RangeVal: 0
    }
    );


    Set(
    StartRange,
    First(
    Sort(
    RangeValues,
    RangeStart,
    SortOrder.Descending
    )
    ).RangeStart
    );
    Notify(Text(StartRange),NotificationType.Information);
    If(
    StartRange = "",
    Set(
    StartValue,
    0
    );
    Set(
    EndValue,
    2
    ),
    Set(StartValue,
    StartValue+2);

    Set(
    EndValue,StartValue+2);
    );
    Collect(
    RangeValues,
    {
    RangeStart: StartValue,
    RangeEnd: EndValue,
    RangeVal: RandBetween(
    1,
    100
    )
    }
    );

    2. Add A gallery and place below code at Item Property

     

         Filter(RangeValues,RangeVal<>0)

     

  • Verified answer
    Abhilash_Swain Profile Picture
    901 on at

    Hi @Kepcla ,
    Hope you are doing good . please find a sample code.  Used an excel table to simulate the same scenario.

    //Collecting data into 2 temp records to show the transformation
    Concurrent(ClearCollect(colinitial,Table1),ClearCollect(coltemp,Table1));
    //Creating a temp sequence table to add the sequenceing
    ClearCollect(colsequence,Sequence(CountRows(Table1),0,2));
    // Updating the temp collection to have the sequence
    ForAll(Table1,Patch(coltemp,First(Filter(coltemp,Value=ThisRecord.Value,FROM="")),{FROM:Value(First(colsequence).Value)},{To:Value(First(colsequence).Value)+2});
    //Remove the top row to support the logic
    Remove(colsequence,First(colsequence)));
    //Final patch to update the data into the source
    Patch(Table1,coltemp);
    //Refresh the source
    Refresh(Table1)

    Abhilash_Swain_0-1696969064616.png

    Please like/mark as solution if it helps .
    Thanks

    Abhi

     

     

  • Kepcla Profile Picture
    on at

    Hi @Abhilash_Swain , it works! ...

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 206

Last 30 days Overall leaderboard