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
zap2zero
Helper I
Helper I

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)

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
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.