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
Community Support
Community Support

Re: Custom ID that counts and resets each year

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

Re: Custom ID that counts and resets each year

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.
Highlighted
Frequent Visitor

Re: Custom ID that counts and resets each year

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
Community Support
Community Support

Re: Custom ID that counts and resets each year

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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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