cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Re: Retain file name column when using Folder as a data source - Power Query M

Hi @sljean17,

please post sample data of:

1) The source (step "Changed Type") and

2) Your desired result

Thanks.

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




Gabrielms123 Frequent Visitor
Frequent Visitor

Re: Retain file name column when using Folder as a data source - Power Query M

Hey Imke! 

 

Thanks for all the support. 

I have a slighly different problem and since I'm new to M I don't know how to proceed. 

 

In my case, I need to keep the creation date of the document, as I may benefit from it for some calculations.

How can I transform the creation date into a new column in Power Querry?

 

Thanks

Super User
Super User

Re: Retain file name column when using Folder as a data source - Power Query M

The column should be/stay there, if you don't use Combine Binaries but use the method I've described and add a column to retrieve the data from the "Content"-column.

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




RachelEKatz95 Regular Visitor
Regular Visitor

Re: Retain file name column when using Folder as a data source - Power Query M

Hi @ImkeF,

 

I am doing something a little bit different and was wondering if you could help guide me in my use case. I have a SharePoint folder where different CSVs will be uploaded with different headers. Each csv will have at least one of the common merge headers, so there will always be "Key1", "Key2", or "Key3" as one of the headers - the rest might have extra data. I am trying to modify my power query to handle these cases, so that if the file only has "Key2" - just that column will be read in and the rest ignored. Or if it just has "Key1" and "Key2" - those will be read and the rest ignored.. etc

 

I created a sample file with 3 columns for the 3 keys for my default file, but I need help modifying my query because right now the new files just read the first 3 columns of data and doesn't search for "Key2" in the data. Any help on this use case?

 

Thanks in advance for the help!

Highlighted
Super User
Super User

Re: Retain file name column when using Folder as a data source - Power Query M

You have to select the 3 columns in your function before you expand. Therefore you have to modify the Table.SelectColumns-command to cater for missing columns:

 

Table.SelectColumns(AppendToSource,{"Key1", "Key2", "Key3"}, MissingField.Ignore)

That way, any of the 3 key-columns will be selected and no error will be thrown if one or more of them are missing.

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries