cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Custom ID that counts and resets each year

Relatively new to PowerApps and reaching out to the community for assistance with building a custom ID that countss the number of containers in a waste stream created annually and resets each year. 

Example: YY-WasteType-## or 20-Battery-1.  This would be the first container of batteries created in the year 2020.  Next container of batteries would be 20-Battery-2 and so on.  In 2021 the ID would be 21-Battery-1.  I have figured out how to capture the year and wastetype, but I am struggling with the last digit and how to count and reset each year.  

 

Writing my data from PA to a SP List.  Currently I am using the largest ID number.

First(Sort('Container Log',ID,Descending)).ID+1)

Complete code....

If(varFormMode="Edit", varContainerNo, Text(Now(),"[$-en-US]yy") & "-" & Dropdown5.Selected.Title & "-" & First(Sort('Container Log',ID,Descending)).ID+1)
 

Any suggestions on how to accomplish the yearly count and reset of the last digit of this custom container ID would be greatly appreciated.

 

Capture.PNG

 
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi @knightjl ,

Well, I don't think only using delegate function could achieve the feather that you want.

Because you want to reset ID per month, after you filter based on month, how could you know how many records has existed with the value of current month?

That needs CountRows() function.

While there's no delegate function with the feather of counting number.

The delegate functions:

Item Number Text Boolean DateTime Complex [1]
Filter Yes Yes Yes No [4] Yes
Sort Yes Yes Yes Yes No
SortByColumns Yes Yes Yes Yes No
Lookup Yes Yes Yes No Yes
= Yes Yes Yes No [4] Yes
<, <=,<>, >, >= Yes [2] No No No Yes
StartsWith - Yes - - Yes
IsBlank - No [3] - - No

So if your records are smaller than 2000, just leave the delegation warning alone. You just need to change the delegate limit to 2000.

delegation.jpg

 If your record is larger then 2000, please consider save your data to collection.

Then using the formula that I suggested in collection.

Collection does not have delegate problem.

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Highlighted
Community Support
Community Support

Hi @knightjl ,

Do you want to get a text like this "20-Battery-1"?

If so, since you want to reset ID every year, you need to filter firstly. Also, since the ID number that you want is not directly equal to ID

 field, I suggest you use CoutRows() to represent number.

Try this formula:

Concatenate(Text(Year(Now())),
            "-",
            Dropdown5.Selected.Title,
            "-",
           Text(
                CountRows(
                          Filter(fruit11111,Year(Created)=Year(Now()))
                          )+1
                )
            )

On your side, you should try:

If(varFormMode="Edit", varContainerNo,
   Concatenate(Text(Year(Now())),
            "-",
            Dropdown5.Selected.Title,
            "-",
           Text(
                CountRows(
                          Filter('Container Log',Year(Created)=Year(Now()))
                          )+1
                )
            )
)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for your reply.  I tried using the CountRows function, but this function cannot be delegated so I get a Delegation Warning.

Also note: the Custom ID is dependent upon the Waste Type (ie. Batteries, Aerosols, Solvents) selected.

 

Close, but this is not the solution we are looking for.  Any other ideas?

Highlighted

Hi @knightjl ,

Well, I don't think only using delegate function could achieve the feather that you want.

Because you want to reset ID per month, after you filter based on month, how could you know how many records has existed with the value of current month?

That needs CountRows() function.

While there's no delegate function with the feather of counting number.

The delegate functions:

Item Number Text Boolean DateTime Complex [1]
Filter Yes Yes Yes No [4] Yes
Sort Yes Yes Yes Yes No
SortByColumns Yes Yes Yes Yes No
Lookup Yes Yes Yes No Yes
= Yes Yes Yes No [4] Yes
<, <=,<>, >, >= Yes [2] No No No Yes
StartsWith - Yes - - Yes
IsBlank - No [3] - - No

So if your records are smaller than 2000, just leave the delegation warning alone. You just need to change the delegate limit to 2000.

delegation.jpg

 If your record is larger then 2000, please consider save your data to collection.

Then using the formula that I suggested in collection.

Collection does not have delegate problem.

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,649)