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

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
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
Super User III
Super User III

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.

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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (46,405)