The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi all,
Having a hard time finding a successful example of evaluating parameters aside from TSQL, API calls, and M..
To set the stage, I've got an SSAS Multidimensional Cube model defined with a functional dynamic set that I'll call [YTD Months Set]. This set looks for a single selected month member from a Year - Quarter - Month style hierarchy and based on it, returns all YTD months. In effect, if I were to call an MDX query..
SELECT { [YTD Months Set] }
FROM ( SELECT ( { [Dynamic Set Month Selection].[Month].&[2016].&[4] } ) ON COLUMNS
FROM [CUBE] )
It would return a set of members:
Jan (2016)
Feb (2016)
Mar (2016)
Apr (2016)
My use case involves passing such an MDX query to Power BI to generate a YTD dataset, but I would like to enable end users to specify a Year and Month parameter which would ideally be applied to the query using a StrToMember function.
Something like...
FROM ( SELECT ( { StrToMember('[Dynamic Set Month Selection].[Month].&[' + YearParam + '].&[' + MonthParam + ']') } ) ON COLUMNS
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?
I'm most interested in required settings on the parameter and any syntax requirements for the Query Refresh to detect and apply a defined Power BI parameter
Thanks
Solved! Go to Solution.
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 @v-shex-msft, 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:
Hello,
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 @v-shex-msft, 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:
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
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
95 | |
93 | |
85 | |
68 | |
65 |
User | Count |
---|---|
241 | |
124 | |
120 | |
81 | |
79 |