Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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:
  • Matt8 Profile Picture
    11 on at
    Re: RowNumber in Collection per Category

    @gabibalaban 

     

    Thanks a lot!

    It works like a charm.

  • Verified answer
    CU-18081211-6 Profile Picture
    9,266 Super User 2025 Season 1 on at
    Re: RowNumber in Collection per Category

    @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
    Re: RowNumber in Collection per Category

    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

  • WarrenBelz Profile Picture
    146,679 Most Valuable Professional on at
    Re: RowNumber in Collection per Category

    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

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!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,679 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard