web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : Ezh/kV4FtsBcT7yZhvei+3
Power Apps - Building Power Apps
Answered

RowNumber in Collection per Category

Like (0) ShareShare
ReportReport
Posted on 3 Feb 2024 10:38:19 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)
  • Matt8 Profile Picture
    11 on 03 Feb 2024 at 14:34:45
    Re: RowNumber in Collection per Category

    @gabibalaban 

     

    Thanks a lot!

    It works like a charm.

  • Verified answer
    CU-18081211-6 Profile Picture
    9,266 Moderator on 03 Feb 2024 at 13:15:47
    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 03 Feb 2024 at 12:14:05
    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
    150,917 Most Valuable Professional on 03 Feb 2024 at 11:08:28
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 885 Most Valuable Professional

#2
developerAJ Profile Picture

developerAJ 571

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 352 Super User 2025 Season 2

Last 30 days Overall leaderboard