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

PDF from Folder Multiple Tables and Multiple Pages

HI I have the following scenario and questions:

1. Folder with Multiple PDF Files to Import

2. Each PDF File has multiple Tables --> I tried to select more than 1 table - No Success

3. Each PDF File can have 1 to Several Pages --> Need to consolidate all pages with data into 1 table

 

I'm new to Power Query, so, If someone can guide me step by step, really appreciate

 

Thanks

Lucia

1 ACCEPTED SOLUTION
watkinnc
Super User
Super User

PDFs can be tough to work with. I try to use the same basic strategy every time I use them. I always keep the PageNumber column, sorted ascending, and then add an index column.

Then, in order to get all of your columns, and so the column values remain in the correct positions, you have to sort the tables in the table column by greatest to least count of columns:

 

= Table.AddColumn(NameOfPriorStep, "ColumnCount", each Table.ColumnCount([TableColumn]))

 

Then, sort the ColumnCount column  in descending order. In your case, you could also filter out any tables with 0 columns at this point.

Next, I duplicate this query, and filter to just the Table values ( as opposed to the Page values). Then I filter to just pages in the original query.

Only now do I expand the table column. The very next step is to sort again, this time on your index column. Now, you have all of your columns, all in the correct positions (sometimes, some special characters will cause you trouble, like bullet points), and your pages are in the right order. 

I promise you, if you take these initial steps anytime you work with PDFs in Power Query, your remaining work will be much, much easier!

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

View solution in original post

1 REPLY 1
watkinnc
Super User
Super User

PDFs can be tough to work with. I try to use the same basic strategy every time I use them. I always keep the PageNumber column, sorted ascending, and then add an index column.

Then, in order to get all of your columns, and so the column values remain in the correct positions, you have to sort the tables in the table column by greatest to least count of columns:

 

= Table.AddColumn(NameOfPriorStep, "ColumnCount", each Table.ColumnCount([TableColumn]))

 

Then, sort the ColumnCount column  in descending order. In your case, you could also filter out any tables with 0 columns at this point.

Next, I duplicate this query, and filter to just the Table values ( as opposed to the Page values). Then I filter to just pages in the original query.

Only now do I expand the table column. The very next step is to sort again, this time on your index column. Now, you have all of your columns, all in the correct positions (sometimes, some special characters will cause you trouble, like bullet points), and your pages are in the right order. 

I promise you, if you take these initial steps anytime you work with PDFs in Power Query, your remaining work will be much, much easier!

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors