cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
julianhoewel_95
Level: Powered On

Best way to increment a value in an Excel-Sheet for Document ID

Hey guys,

 

just a quick question. Im trying to find out what's the best way to increment a value in an excel sheet. Right now im storing it in an Excel table (saved in OneDrive) and im incrementing it whenever a certain button is activated in PowerApps and a Flow is triggered. 
In my PowerApps Application I am searching for the highest value in this table and after pressing the button I am adding a new row in this table with the value of the highest+1. Problem is now that these values which im storing in the first row are not getting higher than ten. I found out that this has to do with PowerApps and my question is: What is for you the best way to increment a value in Excel? Is it may better to do this operation in Flow?

An important requirement for me is that this ID can not only reach 10 or 2000, it should be able to reach atleast 10000.

Thanks in advance,

Julian

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Best way to increment a value in an Excel-Sheet for Document ID

Hi @julianhoewel_95 ,

Could you please share a bit more about your scenario?

Do you want to add a new row into your Excel table for each value (e.g. 1,2,3,4,5,...)?

 

If you want to add a new row into your Excel table for each value (e.g. 1,2,3,4,5,...), I agree with @mdevaney 's thought almost, you may face Delegation limits within your app.

Currently, the Excel table is not a delegable data source in PowerApps, in other words, you could only retrieve 2000 records at most from your Excel table.

More details about the Delegation in PowerApps, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview 

 

As an alternative solution, you could consider add a SP List to store the Document ID value. When you want to get the highest Document ID value, please use the following formula:

 

First(SortByColumns('YourSPList', "ID", Descending)).'Document ID'

If you want to add a new row into this SP list, please use the following formula (Set the OnSelect property of a button to following😞

 

 

Patch(
          'YourSPList',
           Defaults('YourSPList'),
            {
                  Title: "Document Number",
                  'Document ID': First(SortByColumns('YourSPList', "ID", Descending)).'Document ID' + 1
            }
)

Note: I assume that the 'Document ID' column is a Number type column in your SP List.

 

 

In addition, it is not necessary to add a new row into your Excel table for each value (e.g. 1,2,3,4,5,...), I think you could use first row of your Excel table to store the Document ID, and update the first row in your Excel table rather than add a new row.

When you want to reference the highest Document ID value from your Excel table, please use the following formula:

 

First('Your Excel Table').ID

Set the OnSelect property of the button to following:

 

 

Patch(
          'Your Excel Table',
           First('Your Excel Table'),
           {
              ID: First('Your Excel Table').ID + 1
           }
)

or

UpdateIf(
              'Your Excel Table',
               true,
                {
                     ID: First('Your Excel Table').ID + 1
                }
)

Please take a try with above solution, check if the issue is solved.

 

Best regards,

 

Community Support Team _ Kris Dai
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

2 REPLIES 2
Super User
Super User

Re: Best way to increment a value in an Excel-Sheet for Document ID

@julianhoewel_95

I strongly advise you to swtich to another datasource instead of Excel.  Once you get over 2,000 rows in Excel you are subject to delegation limits.  Your app will not be able to read past the 2,000th spreadsheet line and increment the number.  Also, any lines past the 2,000th line will not be usable in your app.  To be clear, Excel is OK in some use cases but your you siutation requires a different solution.

 

My suggestion is to transfer your data into a Sharepoint list.  The ID number will always autoincrement and you will not be subject to the delegation limit of 2,000 rows.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

Community Support Team
Community Support Team

Re: Best way to increment a value in an Excel-Sheet for Document ID

Hi @julianhoewel_95 ,

Could you please share a bit more about your scenario?

Do you want to add a new row into your Excel table for each value (e.g. 1,2,3,4,5,...)?

 

If you want to add a new row into your Excel table for each value (e.g. 1,2,3,4,5,...), I agree with @mdevaney 's thought almost, you may face Delegation limits within your app.

Currently, the Excel table is not a delegable data source in PowerApps, in other words, you could only retrieve 2000 records at most from your Excel table.

More details about the Delegation in PowerApps, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview 

 

As an alternative solution, you could consider add a SP List to store the Document ID value. When you want to get the highest Document ID value, please use the following formula:

 

First(SortByColumns('YourSPList', "ID", Descending)).'Document ID'

If you want to add a new row into this SP list, please use the following formula (Set the OnSelect property of a button to following😞

 

 

Patch(
          'YourSPList',
           Defaults('YourSPList'),
            {
                  Title: "Document Number",
                  'Document ID': First(SortByColumns('YourSPList', "ID", Descending)).'Document ID' + 1
            }
)

Note: I assume that the 'Document ID' column is a Number type column in your SP List.

 

 

In addition, it is not necessary to add a new row into your Excel table for each value (e.g. 1,2,3,4,5,...), I think you could use first row of your Excel table to store the Document ID, and update the first row in your Excel table rather than add a new row.

When you want to reference the highest Document ID value from your Excel table, please use the following formula:

 

First('Your Excel Table').ID

Set the OnSelect property of the button to following:

 

 

Patch(
          'Your Excel Table',
           First('Your Excel Table'),
           {
              ID: First('Your Excel Table').ID + 1
           }
)

or

UpdateIf(
              'Your Excel Table',
               true,
                {
                     ID: First('Your Excel Table').ID + 1
                }
)

Please take a try with above solution, check if the issue is solved.

 

Best regards,

 

Community Support Team _ Kris Dai
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
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

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