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 / Increment value field ...
Power Apps
Answered

Increment value field based on Field category

(0) ShareShare
ReportReport
Posted on by

I have SharePoint list with Field names Category(choice column) and Value(number column). I am using this SharePoint list as data source in PowerApps. My requirement is whenever a new item is created for each category, value should increment respectively. 

Example: If I create new item under category Product, it should value 001 and when I create new item under category Marketing it should value 001. Then next if I again create item under category Product, it should value 002

Category

Value

Product

001

Marketing

001

Product

002

Network

001

Network

002

Product

003

Marketing

002

 

I am new to PowerApps, any help will be greatly appreciated!

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

    Hi @learnpowerapp ,

    If you used this as the Default of the Category Text field in your Form, it should create the next value when one is not already present (new records) - Also Value is a very bad name for a field as it is a Reserved Word for many uses in Power Apps.

    Coalesce(
     ThisItem.Value,
     Text(
     Value(
     LookUp(
     Sort(
     SPListName,
     ID,
     SortOrder.Descending
     ),
     Category = YourCategoryDropdown.Selected.Value
     ).Value + 1
     ),
     "000"
     )
    )

     

    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

  • learnpowerapp Profile Picture
    on at

    @WarrenBelz , thanks a lot for your help, the above formula worked for my requirement to increment value based on Category. However, the values are coming up as 1,2 and not 001,002. Can you please help me with how can I set "00" as prefix in the above formula.

     

    Additionally, thanks for correcting me with regards to column name 'Value'. I will change the name of the column accordingly.

  • WarrenBelz Profile Picture
    153,427 Most Valuable Professional on at

    @learnpowerapp ,

    Text(. . . . ., "000") puts it in this format - did you use the code structure I posted and where did not use it (please post your exact code in Text)

     

  • learnpowerapp Profile Picture
    on at

    @WarrenBelz ,Here is my exact code:

    Coalesce(
    ThisItem.Value,Text(Value(LookUp(Sort('Inventory List',ID,SortOrder.Descending),'Category'.Value=DataCardValue8.Selected.Value).Value+1), "0000")
    )

     

    Here"DataCardValue8 " refers to Category field

  • WarrenBelz Profile Picture
    153,427 Most Valuable Professional on at

    @learnpowerapp ,

    To test the main bit, put this in a label 

    Text(
     Value(
     LookUp(
     Sort(
     'Inventory List',
     ID,
     SortOrder.Descending
     ),
     'Category'.Value = DataCardValue8.Selected.Value
     ).Value + 1
     ), 
     "0000"
    )

     

  • learnpowerapp Profile Picture
    on at

    @WarrenBelz -The above formula works in making the text as "00001" but once the Value changes to double digit, the text is also changing(example: if my item number is 10 the value is changing to "00010"). In my case I want "0000" to be constant. So I tried Concatenate function in the previous formula you have given and it worked for me.

    Concatenate("0000",Coalesce(
    ThisItem.Value,Text(Value(LookUp(Sort('Inventory List',ID,SortOrder.Descending),'Category'.Value=DataCardValue8.Selected.Value).Value+1))
    ))

    Thanks a lot for your help:)

  • WarrenBelz Profile Picture
    153,427 Most Valuable Professional on at

    @learnpowerapp ,

    Sorry, but I am quite unclear now what you want. How can 10 be 0000 ?

  • learnpowerapp Profile Picture
    on at

    @WarrenBelz - I want to showcase my Value field increment in this format for each Category.( where "0000" is a constant text before my Value)

    Below I have taken example of Category: Product

     

    Category

    Value

    Product

    00001

    Product

    00002

    Product

    00003

    Product

    00004

    Product

    00005

    Product

    00006

    Product

    00007

    Product

    00008

    Product

    00009

    Product

    000010

  • Verified answer
    WarrenBelz Profile Picture
    153,427 Most Valuable Professional on at

    @learnpowerapp ,

    Very unusual and changes the whole concept of string construction - you just need to add "0000" on the front of the number

    "0000" & 
    Text(
     Value(
     LookUp(
     Sort(
     'Inventory List',
     ID,
     SortOrder.Descending
     ),
     'Category'.Value = DataCardValue8.Selected.Value
     ).Value + 1
     )
    )

     

    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

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

#2
Kalathiya Profile Picture

Kalathiya 361

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 339 Super User 2025 Season 2

Last 30 days Overall leaderboard