Forum Discussion
Dynamic parameter in Power Query
- 1 year ago
Hi 一棵黄葛树,
Thank you for the update. We sincerely apologise for the inconvenience caused.
Please find attached the PBIX file and a screenshot for your reference, which may assist in resolving the issue.
If you find our response helpful, kindly mark it as the accepted solution and consider providing kudos. This will assist other community members facing similar queries.
Thank you.
Thank you, AlienSx and Omid_Motamedise , for your response.
Hi 一棵黄葛树,
We sincerely appreciate your inquiry on the Microsoft Fabric Community Forum.
As per my understanding, if we intend to use the parameter, we cannot input code in the 'Current Value' field of the Manage Parameters screen; instead, we must enter the date.
As an alternative, if we wish to use the code, we need to define the parameter separately in the Advanced Editor and then reference it accordingly. Kindly refer to the attached sample code and images provided below:
let
Source = Csv.Document(File.Contents("C:\Users\v-pnaroju\Downloads\sampledata.csv"),[Delimiter=",", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type datetime}, {"Sales", Int64.Type}}),
MyParam=Date.AddDays(Date.StartOfMonth(DateTime.LocalNow()), -1),
FilterRows=Table.SelectRows(#"Changed Type",each [Date]<MyParam)
in
FilterRows
Additionally, please find below the reference links for your convenience:
Dynamic M query parameters in Power BI Desktop - Power BI | Microsoft Learn
Parameters - Power Query | Microsoft Learn
If you find our response helpful, we kindly request you to mark it as the accepted solution and provide kudos. This will assist other community members encountering similar queries.
Thank you.