Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - AI Builder
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

Categories:
  • Fabio Filardi Profile Picture
    2 on at
    Re: Increment an integer variable for each detail line read on an invoice

    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.

     

  • antoinec Profile Picture
    on at
    Re: Increment an integer variable for each detail line read on an invoice

    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?

  • shadiya Profile Picture
    45 on at
    Re: Increment an integer variable for each detail line read on an invoice

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 770 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 494

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 399