I import many textfiles from a folder with subfolders, everything works fine so far. My folder has the same text file in many folders for different Periods, so e.g.:
AllData\201501\Revenues.txt
AllData\201502\Revenues.txt
AllData\201502\Revenues.txt
.....
I need a Part from the path like "201501" inside my query which is preparing the Revenues. I can't write the date into the .txt file, is generated from third party.
How can I join the FullPath on my text file rows? Cutting it after that is simple.
(Sorry if any of the features below aren't in the public release of Power Query yet--this works in the Power BI Designer today!)
From Folders gives me:
Add a custom step using
Text.FromBinary
with a column namedText
to get the file text:Then remove every column except
Folder Path
andText
:From there, split the Folder Path column by delimiter
\
And then only keep the path column with the date:
Next, merge the two text columns with a custom
:
, and you're done!Run this to set up the data used above:
Full M source code for this transformation: