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 / Insert Sequence Number...
Power Apps
Answered

Insert Sequence Number Function into an Item Gallery

(0) ShareShare
ReportReport
Posted on by 349

In an Gallery for the Item Property, I have the following definition:
ForAll(Filter(MR_POH,JobNo=Job_Gallery.Selected.JobNo &&
(Dropdown1.Selected.Value=Status || Dropdown1.Selected.Value="ALL")) As _item,
With(LookUp(
DropColumns(
AddColumns(
GroupBy('[dbo].[MR_POL]',"PackageNo","GroupedItems"),
"QTYSUM",Sum(GroupedItems,QTY)
),
"GroupedItems"),
PackageNo = _item.PackageNo),
Patch(_item,
{
QtySum: QTYSUM
})))

I'd like to include a sequential row number for each row using the Sequence function returned in above result set. 

Sequence function in Power Apps - Power Apps | Microsoft Docs

Thank you


 

Categories:
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    It's not pretty, but if you have an items property set to the expression X, you can add an index to it using an expression similar to the one below:

     

    With(
     { coll:X },
     ForAll(
     RenameColumns(Sequence(CountRows(coll)),"Value","Index") As Idx,
     Patch(Idx, Last(FirstN(coll, Idx.Index)))))

     

    For your scenario, if you replace 'X' in the expression above with your original expression, you should get a new column called 'Index' in your gallery, something like the expression below:

    With(
     { coll: ForAll(
     Filter(
     MR_POH,
     JobNo = Job_Gallery.Selected.JobNo && (Dropdown1.Selected.Value = Status || Dropdown1.Selected.Value = "ALL")) As _item,
     With(
     LookUp(
     DropColumns(
     AddColumns(
     GroupBy('[dbo].[MR_POL]', "PackageNo", "GroupedItems"),
     "QTYSUM", Sum(GroupedItems, QTY)),
     "GroupedItems"),
     PackageNo = _item.PackageNo),
     Patch(_item, { QtySum: QTYSUM })))
     },
     ForAll(
     RenameColumns(Sequence(CountRows(coll)),"Value","Index") As Idx,
     Patch(Idx, Last(FirstN(coll, Idx.Index)))))

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard