PowerQuery - PDF file with varying number of columns

Spinoza

New Member
Joined
Oct 11, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi everyone !

I have a problem with a very simple Query that I'v made using PowerQuery. Let me explain the Query...

- I import a PDF file that contains normally 6 columns, one columns contains the name of the account while the 5 others contains financial data for the last 5 fiscal year.
- When I refresh the data with another PDF file that contains 5 fiscal years, I do not have any problem, my Query works perfectly.
- You see me coming ? ;) My problem is when my a refresh the data with a PDF file that contains less than 5 fiscal years, I got an error message that I missed column #6.

Anybody could help me to resolve that issue please ?

Thanks a lot and wonderful day to you !

Francis
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
You could use the Table.SelectColumns command with the MissingField.Ignore parameter, something like this:

Power Query:
let   
    Source = Pdf.Tables(File.Contents("C:\path\to\Data.pdf"), [Implementation="1.3"]),
    Page1 = Source{[Id="Page001"]}[Data],
    Table1 = Table.SelectColumns(Page1,{"Column1", "Column2", "Column3", "Column4", "Column5", "Column6"}, MissingField.Ignore),
    Table2 = Table.PromoteHeaders(Table1, [PromoteAllScalars=true])
in
    Table2
 
Upvote 0

Forum statistics

Threads
1,216,113
Messages
6,128,904
Members
449,477
Latest member
panjongshing

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top