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

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
v-xida-msft
Community Support
Community Support

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

@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."

 

 

v-xida-msft
Community Support
Community Support

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

Power Apps Community Call

Monthly Power Apps Community Call

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

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (42,824)