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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

How to import two folders with different data

Hello,

 

I am struggling to get two folders imported which contain different types of CSVs.

 

When I add the second folder as source, the query editor shows the helper queries from the first folder and when I modify them, the first folders data gets messed up.

Here is, how my query editor looks like as an image.

 

I'd need a new "Transform File" and "Transform Sample File" function for the second folder but I don't know how to create it.

 

Can anyone point me in the right direction?

 

Zap.

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

the helper functions are very nice when you are new to Power Query and the M language.  Once your knowledge has increased you will find that they are rather ineffective and that they can be simplified a lot, and even can be eliminated in some cases.

 

Two options:

1. rename your existing helper function components for the first folder before creating the query for the second folder.

2. Create a M function that does everything the helper functions do, but in a more elegant way.

 

Example for 2:

 

 

(Parameter) => let
        Source = Csv.Document(Parameter,[Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.Csv]),
        #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
        Selected = Table.SelectColumns(#"Promoted Headers",Columns)
in
    Selected

 

 (Note: "Columns" is a list of desired column - this is done to filter the source files early, and to avoid having to load the "Sample File" twice like the helper function does)

View solution in original post

3 REPLIES 3
AllisonKennedy
Super User
Super User

You should be able to use the Get Data > From Folder twice, and point to the two different folders, then do an append to combine them once they're both in the same format. 

 

Otherwise see if this exercise helps you understand the helper queries a bit better: 

Use Parameters to Combine Data 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

lbendlin
Super User
Super User

the helper functions are very nice when you are new to Power Query and the M language.  Once your knowledge has increased you will find that they are rather ineffective and that they can be simplified a lot, and even can be eliminated in some cases.

 

Two options:

1. rename your existing helper function components for the first folder before creating the query for the second folder.

2. Create a M function that does everything the helper functions do, but in a more elegant way.

 

Example for 2:

 

 

(Parameter) => let
        Source = Csv.Document(Parameter,[Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.Csv]),
        #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
        Selected = Table.SelectColumns(#"Promoted Headers",Columns)
in
    Selected

 

 (Note: "Columns" is a list of desired column - this is done to filter the source files early, and to avoid having to load the "Sample File" twice like the helper function does)

Anonymous
Not applicable

Thank you for your answer! I used the option to rename the functions which I didnt think of before (obviously) and afterwards it was pretty simple to add my second data source!

 

Zap.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.