Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Is there an straightforward way in PQ or via a formula, new column, or measure to get the text from the name of the file being imported?
Or do I have to redo a few things and reimport this as a folder import??
Solved! Go to Solution.
Hi,
I understand your Source step equals to "Csv.Document(File.Contents(..."
Copy paste the function below and invoke it in your Source instead.
(Path as text) =>
let
FileName = Text.BetweenDelimiters(Path, "_", ".txt", {0, RelativePosition.FromEnd}, 0),
Txt = Csv.Document(File.Contents(Path),[Delimiter=";", Encoding=1252, QuoteStyle=QuoteStyle.None]),
PromoteHeaders = Table.PromoteHeaders(Txt, [PromoteAllScalars=true]),
FileNameColumn = Table.AddColumn(PromoteHeaders, "FileName", each FileName)
in
FileNameColumn
Hope it helps.
Hi,
I understand your Source step equals to "Csv.Document(File.Contents(..."
Copy paste the function below and invoke it in your Source instead.
(Path as text) =>
let
FileName = Text.BetweenDelimiters(Path, "_", ".txt", {0, RelativePosition.FromEnd}, 0),
Txt = Csv.Document(File.Contents(Path),[Delimiter=";", Encoding=1252, QuoteStyle=QuoteStyle.None]),
PromoteHeaders = Table.PromoteHeaders(Txt, [PromoteAllScalars=true]),
FileNameColumn = Table.AddColumn(PromoteHeaders, "FileName", each FileName)
in
FileNameColumn
Hope it helps.
Hi @comish4lif2 ,
Assuming the file name is part of your Source step you could add a column extracting it using any of the functions you have available.
For instance:
Text.BetweenDelimiters(Source,"\",".")
Is the file name part of my source step?
If I import a txt file, how do I get from "FIlename_06162023.txt" - to "06162023" in its own column.
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!
User | Count |
---|---|
30 | |
25 | |
23 | |
22 | |
21 |