cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MarkB1977
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
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 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.

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (36,141)