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", ""
)
In Power Query, create a new blank query
Enter = [Source.Name] to create a column with the file name
Remove any other columns
Right-click the query and select "Reference" to load it into the model
In DAX, reference this table, e.g. = 'Query Name'[Source.Name]
None of them are working. Any ideas?
DAX and M scripts have been provided by Google, Microsoft Forums, ChatGPT, Perplex and Copilot.
Dmitri Braverman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.