cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
paspuggie48
New Member

AI Builder - Scan each PDF document in specific order?

I am very very new to Power Automate and the AI Builder and successfully created my first automation.

I have multiple documents in name order and a table in each document. Each document has the same column headers and various number of rows of data.

During tests, Power Automate recognises I put one document into a OneDrive folder and then auto-populates the extracted data and puts it an Excel document in the correct header columns. Perfect !

However, when I upload multiple documents the data extracted and put into the Excel document is not in order. It seems to mix the data from any document and puts it in any rows it likes.

Is there a setting to make Power Automate (or AI Builder if it is this) to scan one document first, populate the Excel with that document data, then go to the next document and repeat, so that all data is in order?

1 ACCEPTED SOLUTION

Accepted Solutions
CedrickB
Power Apps
Power Apps

If you use the trigger "When a file is created", there is no guaranty that file will be processed in the order they have been created if you add several in a row.

One option is to temporize the creation of each file.

Another is to add the file creation date when inserting a row in Excel and then sorting the Excel table

See Filter Query, Order By on Excel Rows - Power Platform Community (microsoft.com)

View solution in original post

7 REPLIES 7
CedrickB
Power Apps
Power Apps

If you use the trigger "When a file is created", there is no guaranty that file will be processed in the order they have been created if you add several in a row.

One option is to temporize the creation of each file.

Another is to add the file creation date when inserting a row in Excel and then sorting the Excel table

See Filter Query, Order By on Excel Rows - Power Platform Community (microsoft.com)

Thank you for responding CedrickB and some interesting solutions. Albeit I'm at a basic level I'll have a look at those options.

Many thanks again 🤞

Antrod
Microsoft
Microsoft

Hi @paspuggie48 ,

 

Another option you may want to try is the concurrency configuration of your flow. Please look at this thread for more information: Solved: Allow only 1 instance of a flow to run at the same... - Power Platform Community (microsoft....

 

However if you upload multiple files at a time in a folder, it doesn't guarantee to take a specific order. In that case, you'll need to look at CedrickB's recommendations.

 

Thanks.

Thanks Antrod, unfortunately setting to concurrency of 1 only scanned one document. I'll try CedrickB's option and I think the temporize of creation comment was apt also.

 

So, I thought of having a separate flow to move the files from the current folder (where I copy them from and then to the OneDrive folder) and having a time delay in between the time it takes to copy over each file. Theoretically speaking.

It's strange that a concurrency setting of 1 only caused the one document to scan. It should have queued up the other runs to run one after another (though not in any specific order as others have said). Just out of curiosity, since you didn't post your flow's design, does the flow recreate the Excel spreadsheet every time with the same name? It might be that it did actually process all the files, but overwrote each time. You might not have seen that before you set the concurrency to 1 as the multiple files were all running simultaneously. But you might have seen that not all the data was collected in the spreadsheet in that case.

Thank you for your input Barrett.

 

My apologies, I cannot share the exact data itself because it's sensitive data at work, however I did a comparison. I tested Doc1 by uploading it into my OneDrive folder and Power Automate & AI Builder scans the data row-by-row and the output was perfect, with each row of data in order. I deleted Doc1 and tested Doc2 and again it was perfect, all rows of data were in order.

 

I deleted all docs in that folder and re-tested by uploading both Doc1 and Doc2 at the same time (and they are named differently). What I noticed thereafter is the rows of data were mixed (which I reported before).

 

So in essence it scans Row 1 of Doc1 and then scans Row 1 of Doc2 and populates the Excel table with both of those 2 rows of data. Then it scans Row 2 of Doc1 and then scans Row 2 of Doc2 and uploads both those 2 rows to Excel and repeats until it gets to the end of the page.

 

Maybe its because I'm 'Adding a row into a table' ??

 

paspuggie48_0-1637590192388.png

 

I suppose therefore the question is, how do I have it scan every row until end of page, then upload to Excel then go to the next document and repeat?

 

Yes, if you drop both files at the same time, the flow will trigger multiple times and run simultaneously if the Concurrency config setting is not set to 1. So, dropping two files at the same time, will trigger two flows, one for each file, which will both write to the same destination Excel file at the same time. I would say it's probably luck more than anything that it appeared to alternate back and forth between the source files for each row.

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Users online (1,758)