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

Notifications

Announcements

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

Categories:
I have the same question (0)
  • shadiya Profile Picture
    45 on at
  • antoinec Profile Picture
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard