cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MarkB1977
Helper II
Helper II

Label to return next free list number?

Evening all. 

 

Quick question.  I have a power app writing to a SP list. 

 

The list has unique reference numbers manually entered 2001, 2002, 2003 etc.

 

What I want is a label (I will place in the edit screen) to lookup the last used reference number and add 1.  Essentially providing the next reference number to enter. 

 

So if the last number in the list is 2009.

The label would return 2010

 

Thanks in advance. 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Roser
Frequent Visitor

If you have more than 2000 items I would first sort the list in reverse order and pick the first item.

Value(First(Sort(YourList,Created,Descending)).ReferenceNumber)+1

 

While we are at it, why you don't just use the already existing ID field, which just does this for you automatically?

View solution in original post

3 REPLIES 3
eka24
Super User
Super User

In the label try

First(Sort(Datasource,ID, Descending)).ID

This will give the last ID.

 

To Add

First(Sort(Datasource,ID, Descending)).ID+1

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Roser
Frequent Visitor

If you have more than 2000 items I would first sort the list in reverse order and pick the first item.

Value(First(Sort(YourList,Created,Descending)).ReferenceNumber)+1

 

While we are at it, why you don't just use the already existing ID field, which just does this for you automatically?

View solution in original post

@Roser 

 

That worked perfectly thank you.

 

I eventually went with 

 

If(IsBlank(DataCardValue10), Value(First(Sort('Drug and Alcohol Testing List',Created,Descending)).'Reference Number:')+1,"")

 

 

to only show the next number when the datacard was blank.

 

 

The ID field doesn't allow me to change the numbering system each year eg

 

2001 for Y2020

2101 for Y2021

2201 for Y2022

 

 

It also would leave a gap should an entry be deleted which doesn't look good in a list when presented as data IMO.

 

 

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,358)