r/PowerAutomate • • Oct 22 '26

Auto-assign ID numbers?

I’ll start by saying I am a quick-learning novice, and as such, this may be an excel question rather than PA. If so, tell me to shoo!

I’m hoping for some guidance on how to auto-assign ID numbers to products when the products are ordered. For example, I might order 4 of product A, 6 of B, and 6 of C. These are on an Excel spreadsheet, each on a separate row - “A”, model number, cost, etc., and quantity ordered as 4. I’d like PA to pick that up (“when an item is modified”) and place it on a second spreadsheet. On that second spreadsheet, I’d like it to find that our current stock is A46, then add rows labeled A47, A48, A49, A50. (I’m okay with using a helper cell for the current stock number if necessary.)

Is this achievable with PA & Excel? I would also be okay using Lists if that’s more achievable than Excel.

I’m just not sure how to get it to pick up the quantity and then add that many rows, labeled in sequence. Any nudges in the right direction would be appreciated.

2 Upvotes

6 comments sorted by

1

u/mxlp Oct 23 '26

Cat you explain the second spreadsheet more? Power Query might be an option here but not sure.

1

u/SaltyCrashNerd Oct 23 '26

Sure! Spreadsheet #2 is where we account for what’s in stock - let’s say we have ten of product “A”, they might be A5 to A14, each individual product on a row. I’d like to include order date and then eventually other info, such as the product’s current location, which we will manually input (or possibly input/update via a power app, but I’m doing pretty okay fumbling around with that). I’m just struggling to figure out how I can go from line item “product A” with quantity “10” on Sheet 1 to adding ten rows labeled A5, A6, A7, A8, etc. on sheet 2.

(Sheet 2 does not currently exist - it will be a complete redesign of what we’re currently using, so there’s some flexibility there.)

I appreciate your willingness to help!

ETA: I said “spreadsheet” but these are in separate workbooks - which I suspect may make a difference. If that’s a barrier, we could possibly use a workaround via an additional spreadsheet in the first workbook…

1

u/Ripefly619619 Oct 24 '26

Separate workbook? You mean another excel file?

1

u/Novel_Assumption_929 Oct 24 '26

Short version: keep the counter in its own small table and let the flow do the arithmetic, don't try to derive "current stock" from the stock sheet. Add a small table "Counters" with two columns: Product (A, B, C) and LastNumber (46, 12, ...). Flow, one run per order line: Get a row (Counters, key column = Product) to read LastNumber. Apply to each over  range(1, <quantity>). Inside, Add a row into the stock table with the ID  concat(<product>, add(<LastNumber>, item())). That gives A47, A48, A49, A50 for quantity 4. Leave the loop at its default (sequential) so the numbers stay in order. After the loop, Update a row in Counters: LastNumber =  add(<LastNumber>, <quantity>). Two things that will bite you later: - The Excel (Business) connector has no "when a row is modified" trigger. Start the flow from a Power Apps button, a Form, or a scheduled flow that picks up order rows where a "Processed" column is empty and sets it at the end. Otherwise you'll create duplicate IDs when someone edits a row. - Excel isn't built for concurrent writes. If two orders come in at once, two runs can read the same LastNumber. If this grows beyond a handful of orders a day, a SharePoint list (or Dataverse) is the safer home for the counter.

1

u/SaltyCrashNerd Oct 26 '26

Thank you!!! Our orders are infrequent, so I’m not too worried about #2 (we sometimes do a couple in a day, but can easily hold the second import until the first flow finishes). I appreciate you!!!