Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I am struggling to get the current file name in the Power BI report.
I tried the following solutions:
FileName =
VAR FilePath = LEFT(PATH(), FIND("[", PATH(), 1) - 2)
RETURN
RIGHT(FilePath, LEN(FilePath) - FIND("\", REVERSESTRING(FilePath), 1))
let
Source = #shared,
CurrentWorkbook = Source{[Name="CurrentWorkbook"]}[Content],
FileName = CurrentWorkbook{[Name="Name"]}[Content]
in
Filename
let
Source = #table({"FileName"}, {{Uri.LocalFileFromPath(#shared[Content])}})
in
Source
FileName = FIRSTNONBLANK(FileNameQuery[FileName], 1)
Current File Name = VALUE.NATIVEQUERYMETADATA()[Source.Name]
Current File Name Without Extension =
REPLACELASTSTRING(
VALUE.NATIVEQUERYMETADATA()[Source.Name],
".pbix", ""
)
None of them are working. Any ideas?
Thanks for that but this is not what I need. I am not interested in external file names. I need to get the current pbix file name using DAX or M.
Hi @dbraverman
Thanks for your quirck reply, if you want to get the current pbix file, it is not support in power bi desktop, you can refer to the followign link.
Get the name of .pbix file - Microsoft Fabric Community
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @dbraverman
You can consider try the following solution.
You can put your file to a folder, then use get data from a folder.
e.g Now I have an excel file, then put it into a folder named new folder.
1.Select get data from folder.
2.Select the folder.
3.Transform the data
4.In this case, it has the "~" in Name column, need to filter out the name that contains"~"
5.In power query select the content and name column, then select remove other columns.
6.Then select combine the content.
7.After combine, click the following step. and remove the other steps below this step.
8.Then remove the content column, then extend the transform file column.
Then name will keep
Output
And you can refer to the following advanced code.
let
Source = Folder.Files("xxx"),//your file path
#"Removed Other Columns" = Table.SelectColumns(Source,{"Name", "Content"}),
#"Filtered Hidden Files1" = Table.SelectRows(#"Removed Other Columns", each [Attributes]?[Hidden]? <> true),
#"Filtered Rows" = Table.SelectRows(#"Filtered Hidden Files1", each not Text.Contains([Name], "~")),
#"Filtered Hidden Files2" = Table.SelectRows(#"Filtered Rows", each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files2", "Transform File", each #"Transform File"([Content])),
#"Removed Columns" = Table.RemoveColumns(#"Invoke Custom Function1",{"Content"})
in
#"Removed Columns"
And you can refer to the followng link.
Solved: adding the file name to a column in power query - Microsoft Fabric Community
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
94 | |
86 | |
78 | |
70 | |
63 |
User | Count |
---|---|
114 | |
99 | |
97 | |
65 | |
59 |