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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
se2
Helper II
Helper II

Extract data from PDFS where data not uniform

Hi, I need to loop through some PDFs.  While much of the data is uniform, some lines are not.  I have figured out how to use power query to extract data from individuals PDFs, therefore accouting differences between files, but not sure how to create a loop with conditional logic? to deal with each PDF?

Thank you,

Steve

5 REPLIES 5
Anonymous
Not applicable

Hi @se2 ,

 

Whether the advice given by @vicky_   has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

se2
Helper II
Helper II

OK. I think I will create a custom query and use parameters if needed.  Will add conditional columns to bring in irregular data.  Still not sure how to loop through the files in a folder and apply the custom query to each file.

looks like loops are in m-code but not in the power question menu.

vicky_
Super User
Super User

There isn't really a way to loop through conditions, however, there are some ways around it. 
The easiest built-in method is to use the folder connector - https://learn.microsoft.com/en-us/power-query/connectors/folder. You can try put all your PDFs in the same folder, and then transform one of them. Once you load it into your data, the transformation will be applied to all PDFs in the file. With this method, the same tranformations are applied to all files in the folder, so there's not a lot of flexibility.

 

Otherwise, there are ways to write functions in M - this will be a bit more involved coding-wise. I recommend checking out https://blog.crossjoin.co.uk/2016/05/15/creating-m-functions-from-parameterised-queries-in-power-bi/...and https://learn.microsoft.com/en-us/power-query/custom-function for more details.

Thank you, I will try

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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