Forum Discussion
Passing parameters to MDX source queries
- Anonymous9 years ago
Hi akwAUBI,
>>Is it possible to configure this sort of parameter within the Power BI Query Editor > Manage Parameters interface and pass it to an in-line query definition in Power BI desktop?
Yes,it is possible, you can take a look at below link:
Create a list then pass as parameters to TSQL
Regards,
Xiaoxin Sheng
- 9 years ago
Thanks Anonymous, it took me a moment to look past the TSQL vs MDX application in realization that the M script is really where the parameter interaction should be configured. For anyone else interested, I concluded the following from what Xiaoxin referenced:
"function formula:
let
loadDataBase=(ServerName as text,DataSource as text, parameter as text) as table=>
let
SQLQuery = "select * from test1121 where Quarter in ("& parameter &")",
Source = Sql.Database("ServerName", "DataSource",[Query=SQLQuery])
in
Source
in
loadDataBase"
Per my initial post, I seemed to have been overly concerned with the MDX StrToMember function being at the core of successfully evaluating my parameter. the M syntax stores the query, be it MDX, TSQL or otherwise, as a single string which should be concatenated in the M context to slot-in a given parameter.
Two extra points I needed to resolve were:- Parameter name needed to be a single word
- My parameter value was an integer (1-12 to represent months) so I needed to supply an M syntax int to string conversion as follows: & Number.ToText(ReportingMonth) &
Hi akwAUBI,
>>Is it possible to configure this sort of parameter within the Power BI Query Editor > Manage Parameters interface and pass it to an in-line query definition in Power BI desktop?
Yes,it is possible, you can take a look at below link:
Create a list then pass as parameters to TSQL
Regards,
Xiaoxin Sheng
Thanks Anonymous, it took me a moment to look past the TSQL vs MDX application in realization that the M script is really where the parameter interaction should be configured. For anyone else interested, I concluded the following from what Xiaoxin referenced:
"
function formula:
let
loadDataBase=(ServerName as text,DataSource as text, parameter as text) as table=>
let
SQLQuery = "select * from test1121 where Quarter in ("& parameter &")",
Source = Sql.Database("ServerName", "DataSource",[Query=SQLQuery])
in
Source
in
loadDataBase
"
Per my initial post, I seemed to have been overly concerned with the MDX StrToMember function being at the core of successfully evaluating my parameter. the M syntax stores the query, be it MDX, TSQL or otherwise, as a single string which should be concatenated in the M context to slot-in a given parameter.
Two extra points I needed to resolve were:
- Parameter name needed to be a single word
- My parameter value was an integer (1-12 to represent months) so I needed to supply an M syntax int to string conversion as follows: & Number.ToText(ReportingMonth) &
- Smasroor8 years agoFrequent Visitor
Hi akwAUBI,
i am struggling with similar issue. I have a list of employee names in my parameter dropdown (populated using a query). I want to pass the parameter value selected by user to the main MDX query that pulls all the data points. Would you be able to plaease share step by step process with screenshots and syntex.
Thanks SM