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 / RowNumber in Collectio...
Power Apps
Answered

RowNumber in Collection per Category

(0) ShareShare
ReportReport
Posted on by 11

Hello,

 

first of all I want to thank all the people writing in this place. I have learned so much since I started with PowerApps one year ago.

 

There is one problem I have, I did not found a solution in the internet.

 

I have a simple Collection with 3 columns, in the example I use Company and Model, plus an added RowNumber column.

I would like to use a RowNumber starting with 1 for each Company.

 

CompanyModelRowNumber
ByCompany
FordF1501
FordEdge2
FordRanger3
FordP1004
BMWZ11
BMW3212
HondaAccord1
HondaCivic2
HondaS20003

 

It is no problem for me to add a RowNumber of all records (1, 2, 3, 4, 5, 6, 7, 8, 9) in the Collection.

But this rank by Company gives me headache for 2 days now.

 

Can someone please help me?

Thank you

Matt

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,494 Most Valuable Professional on at

    Hi @Matt35 ,

    Do you simply want each company in RowNumber Order ?

    SortByColumns(
     ListName,
     "Company",
     SortOrder.Ascending,
     "RowNumber",
     SortOrder.Ascending,
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Matt8 Profile Picture
    11 on at

    Hi Warren,

     

    thanks for your quick response.

     

    Guess I expressed myself wrong.

     

    The data I collect are only two columns:

     

    CompanyModel
    FordF150
    FordEdge
    FordRanger
    FordP100
    BMWZ1
    BMW321
    HondaAccord
    HondaCivic
    HondaS2000

     

    While collecting, I am adding a "RowNumber"-column with value 0

     

     

    ClearCollect(CollectionName, AddColumns(ListName, "RowNumber", 0))

     

     

     

    The current situation after collecting is as below:

     

    CompanyModelRowNumber
    FordF1500
    FordEdge0
    FordRanger0
    FordP1000
    BMWZ10
    BMW3210
    HondaAccord0
    HondaCivic0
    HondaS20000

     

    Now my wish is to fill the RowNumber column as marked in my first post in blue.

    I would need the RowNumber for later use.

     

    I can use below code to get RowNumbers +1 for each record (1 to 9 in this example):

     

     

     

    With(
     {
     _records: CollectionName
     },
     ForAll(
     _records,
     UpdateIf(CollectionName, RowNumber = 0, {RowNumber: Max(CollectionName, RowNumber)+1})
     )
    )

     

     

     

    But I did not found a way to achieve the goal I have, generating a RowNumber by "Company".

     

    It would be great if there will be a possibility.

    Kind regards

    Matt

  • Verified answer
    CU-18081211-6 Profile Picture
    9,270 Moderator on at

    @Matt35 ,

    Using your logic, the adapted formula should be: 

     

     

    With(
     {_records: CollectionName},
     ForAll(
     _records,
     UpdateIf(
     CollectionName As baseTable,
     RowNumber = 0,
     {
     RowNumber: Max(
     Filter(
     CollectionName,
     Company = baseTable.Company
     ),
     RowNumber
     ) + 1
     }
     )
     )
    )

     

     

     

  • Matt8 Profile Picture
    11 on at

    @gabibalaban 

     

    Thanks a lot!

    It works like a charm.

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 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard