Hello CarlosDash
I am in similar situation like this , i have huge DB that i can not download all together so need user to be able to select parameters and then get data ccordingly , how did you approach it ? Can you please help me here .
Here's an example I got working using the AdventureWorks DB.
I created a sproc that accepts one int parameter. I created a parameter in PowerBI of type ANY called IDIN.
Here's my query:
= Sql.Database(".\MSSQLSERVER2016", "AdventureWorksDW2014", [Query="Exec dbo.testfrompbi "&IDIN&"", HierarchicalNavigation=true])
Please convert data type using Number.ToText(param)
All the tutorials and posts I saw were about how to pass the query parameter in the 'M' query in Power BI advance editor and nothing about how to actually pass a parameter by editing the souce query SQL statement.
Any idea about that?
The main problem with adding the parameter in the Advanced Editor is that, once its edited there, then the setting wheel next the Source of the query disappears and there is no way to see or edit your SQL statement after that.
Any more insights on this? Does Power BI support passing a parameter to the SQL query?
Hey did you get any work around for the same?
I have also been working on Huge Set of tables and need to filter them based on the bases of date.
Please let me know is there a way to implement the same.
Appreciate the Help!
Step one is creating your custom SQL statement. I like to add my placeholder for a parameter when I create the SQL statements and replace those with the parameter once defined. The parameters need to be concatenated to the query using & outside of the quotes holding the query. If you created a table with a single SQL query, your M may look like the following.
Non-Parameterized Query
let
Source = Sql.Database("MyTestServer", "MyTestDatabase", [Query="SELECT test_key from MyFactTestTable WHERE datekey >= 20190101 AND datekey <= 20190201"])
in
Source
Parameterized Query
let
Source = Sql.Database("MyTestServer", "MyTestDatabase", [Query="SELECT test_key from MyFactTestTable WHERE datekey >= " & StartDate & " AND datekey <= " & CloseDate"])
in
Source
What editor in Power BI were you using to enter this code?
I want to do this for my MYSQL data and pass parameters through my query code.
Please let me know.
Thanks.
User | Count |
---|---|
127 | |
80 | |
78 | |
70 | |
69 |
User | Count |
---|---|
124 | |
74 | |
66 | |
56 | |
52 |