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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Auto-increment column ...
Power Apps
Answered

Auto-increment column by one depending on other column

(1) ShareShare
ReportReport
Posted on by 27

Hi All,

 

For simplicity, I have two columns: system and counter. I would like to automatically increment the counter column by one, but depending on what system is selected, so for system A, system B and system C I would use 1...2...3...4...5 etc. I assume that I should use some kind of maximum function. In the example below, for a new record A, the counter is 4, for record B it is 3. There are several people working in the application, so the value of the counter should be calculated directly before patching.

 

kzoltan_0-1684221969646.png

I would appreaciate any help.

Thanks,

Zoltan

 

Categories:
I have the same question (0)
  • KeithAtherton Profile Picture
    3,705 Most Valuable Professional on at

    Hi @kzoltan,

     

    Try the following code, where the counter is incremented when new records are added to the data collection:

    ClearCollect(colSystemCounter, Blank());
    
    Set(gblSystem, "A");
    
    Collect(colSystemCounter,
     {
     System:gblSystem,
     Counter:Max(Filter(colSystemCounter, System = gblSystem), Counter) + 1
     }
    );
    
    Set(gblSystem, "B");
    
    Collect(colSystemCounter,
     {
     System:gblSystem,
     Counter:Max(Filter(colSystemCounter, System = gblSystem), Counter) + 1
     }
    );
    
    Set(gblSystem, "C");
    
    Collect(colSystemCounter,
     {
     System:gblSystem,
     Counter:Max(Filter(colSystemCounter, System = gblSystem), Counter) + 1
     }
    );
    
    Set(gblSystem, "A");
    
    Collect(colSystemCounter,
     {
     System:gblSystem,
     Counter:Max(Filter(colSystemCounter, System = gblSystem), Counter) + 1
     }
    );
    
    Set(gblSystem, "B");
    
    Collect(colSystemCounter,
     {
     System:gblSystem,
     Counter:Max(Filter(colSystemCounter, System = gblSystem), Counter) + 1
     }
    );
    
    Set(gblSystem, "A");
    
    Collect(colSystemCounter,
     {
     System:gblSystem,
     Counter:Max(Filter(colSystemCounter, System = gblSystem), Counter) + 1
     }
    );
    
    ClearCollect(colSystemCounterSorted,
     SortByColumns(colSystemCounter,
     "System", SortOrder.Ascending,
     "Counter", SortOrder.Ascending
     )
    );

    KeithAtherton_0-1684225720620.png


    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.
    Follow me online.

  • kzoltan Profile Picture
    27 on at

    Hi @KeithAtherton ,

     

    Many thanks for the answer.

    Your solution is not exactly what I was looking for, but it helped me a lot.

     

    1.) Created a collection:

     

    ClearCollect(
    colSystemCounter,
    ShowColumns(
    SP_list_name,
    "System",
    "Counter"
    )
    );

     

    2.) Created an "Edit form" control and in the update property of Card: Counter, I put the following code:

     

    Max(Filter(SP_list_name,System = SystemCardValue.Text), Counter + 1)

     

    However there is a delegation warning: 

    "Delegation warning. The highlighted part of this formula might not work correctly on large data sets. The 'Max' operation is not supported by the connector"

     

    Is there any way to get rid of this warning? There will be 5-10k records in the datasets.

     

    Thanks,

    Zoltan

     

     

     

     

     

  • Verified answer
    KeithAtherton Profile Picture
    3,705 Most Valuable Professional on at

    Try changing the code to the following so that the filtered list is stored as a local data collection first, then you can apply the Max function. If you get more delegation warnings, you may need to trial-and-error the code:

    ClearCollect(colMyList, Filter(SP_list_name,System = SystemCardValue.Text));
    Set(gblCounterValue, Max(colMyList, Counter + 1));

     

    Also, here's a useful article regarding SharePoint Delegation for Power Apps:

    https://www.matthewdevaney.com/sharepoint-delegation-cheat-sheet-for-power-apps/


    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.
    Follow me online.

  • kzoltan Profile Picture
    27 on at

    Thanks, it is working, perfect!

  • KeithAtherton Profile Picture
    3,705 Most Valuable Professional on at

    Good news! My pleasure. Thanks for the update.


    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.
    Follow me online.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard