web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Increment an integer v...
Power Apps
Unanswered

Increment an integer variable for each detail line read on an invoice

(0) ShareShare
ReportReport
Posted on by 45

Hello,

 

Am working on building an invoice processing model. While creating different collections, I came across some invoices where there is no line number on the invoice. My model is reading the information on an invoice uploaded on SharePoint and exports the information into a CSV file on SharePoint. 

The Invoice line number is one of the primary keys in the table where I am trying to insert the data into, so if it is not available on the invoice, I need to generate it automatically. So, I thought of creating an integer variable and increment it every time the Invoice processing solution would detect a line in the table on the invoice. The variable is incremented successfully. However, when the data is inserted into a CSV file, it keeps the last value of the variable. For example , if there were 4 lines on the invoice , the invoice line number on the invoice gets inserted as 4 for all lines instead of 1,2,3,4.

 

I did not want to rewrite the whole flow - so in Power Automate, I have created a separate loop to deal with the invoice number issue. That's why in my screenshots, you will see 2 'Create CSV table'.

 

Am attaching some screenshots to help with the problem description.

 

Can you please help me ?

 

Thank you

 

Shadiya

Flow - Part 1.JPG
Flow - Part 3.JPG
Flow - Part 2.JPG
Categories:
I have the same question (0)
  • shadiya Profile Picture
    45 on at
    CSV Output - 2.JPG
    CSV Output.JPG
    Flow - Part 4.JPG
  • antoinec Profile Picture
    Microsoft Employee on at

    Hi shadiya,

    Is the for each loop setup to run each iteration sequentially, or are they running concurrently as per default behavior?

    Concurrent loop iterations and variables don't play nicely in Power Automate/Logic Apps: https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-control-flow-loops#foreach-loop . Setting up the loop to run sequentially might help get predictable variable operations: https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-control-flow-loops#sequential-foreach-loop .

    Does this help?

  • Fabio Filardi Profile Picture
    2 on at

    Hi Shadiya,

     

    I had exactly the same issue in the past with Logic Apps. Setting the degree of parallelism to 1 (For Each action settings) solve the issue.

     

    FabioFilardi_0-1666777630469.png

     

    Good luck.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 531 Most Valuable Professional

#2
Haque Profile Picture

Haque 261

#3
Kalathiya Profile Picture

Kalathiya 221 Super User 2026 Season 1

Last 30 days Overall leaderboard