Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

2 REPLIES 2
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!!

Hi watkinnc, could you please suggest any suitable videos for the above explanation if availble. Thank you 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors