Combine and Sort Multiple PDF Files in Excel Power Query
Question details
Combine data from multiple PDF files and sort the resulting records by date and hour.

- Product
- Microsoft Excel Power Query
- Device & OS
- not provided
- Scenario
- Each PDF contains data for a separate date, and the user wants one date- and time-sorted table.
- Observed behavior
- The desired result is a combined table with a usable date and time for each record.
Place the PDFs in one folder and check that their tables have a consistent layout. Identify whether each date comes from the file name or the PDF content, and check how the hour is represented.
Combine PDF tables from a folder and sort by date and time
Use Power Query to apply the same extraction steps to similarly structured PDFs and load a sorted table into Excel.
In Excel, select Data > Get Data > From File > From Folder, choose the PDF folder, and select Transform Data. Filter the Extension column to .pdf if the folder contains other file types.
Select Combine Files on the Content column, or use Combine > Combine & Transform Data. In the sample-file dialog, select the table or page containing the records and confirm. Check the preview to make sure the extracted columns are correct.
If the date is in the PDF table, keep that column. If it is in the file name, keep the source-name column, select it, and use Add Column > Extract to isolate the date portion. Set the resulting column's data type to Date; use Change Type > Using Locale if the date format needs a specific locale.
Select the column containing the hour or time and choose Data Type > Time if it contains time values. If it contains only numeric hours, set it to a numeric type instead.
With the date and time columns typed, use the Power Query formula bar to add a step such as = Table.Sort(#"Changed Type", {{"Date", Order.Ascending}, {"Hour", Order.Ascending}}). Replace the previous step and column names with those in your query, then select Home > Close & Load.

Work with Extracted PDF Data in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format support for moving existing files. After extracting PDF data into a spreadsheet, you can review and sort it in WPS Spreadsheets; it does not fix Excel Power Query or replace the folder-combine workflow described above.

Frequently Asked Questions
Do I need to export each PDF separately before combining it?
Not necessarily. In Excel, Data > Get Data > From File > From Folder can combine similarly structured PDF files using a sample-file transformation.
How can I use a date from each PDF file name?
Keep the source-name column after combining the files, then use Add Column > Extract to isolate the date text. Change the new column to the Date type, using a locale if necessary.
Why are my dates or hours sorting in the wrong order?
They may be stored as text. In Power Query, select the date column and set its data type to Date; set time values to Time or numeric hours to a numeric type before sorting.
What if the PDFs have different table layouts?
The sample-file transformation may not extract every file correctly. Check the combined preview and, if necessary, group files by layout and create a separate query for each group before combining the results.




