Forum Discussion

bmanahan's avatar
bmanahan
New Member
2 years ago
Solved

Dynamic SQL Query with Parameters from URL

We want to use Power BI for reporting for our distributors in their back office.  Many of the reports require computationally intensive processes that must be done on the SQL server for each individu...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi bmanahan ,

    May I ask if this is the Power Bi paramater you are referring to:

    If yes, then your needs cannot be realized. The Power BI parameter and the Power Query parameter are two different things and there is no way they can be linked together. And Power BI parameter can not be used to create a dynamic SQL query.

    You can achieve a similar effect by using DirectQuery and dynamic M query parameters to control your SQL query based on slicer or filter selections in your report:
    Bind this table's field to a Power Query parameter as described in this documentation. This allows the selection in a slicer or filter to dynamically adjust the query parameter.
    Use a slicer in your report for distributors to select the distributor ID, which then dynamically adjusts the SQL query through the bound parameter.
    While this approach does not directly use the URL parameter to adjust the Power Query parameter, it provides a way to dynamically control the data being queried based on user interaction with the report.

    As an alternative, consider using Power Automate to trigger your SQL queries with the distributor ID as an input parameter. Power Automate can then process the data as needed and push the results into a Power BI dataset. Use Power Automate to create a flow that triggers the extraction process. You can set the flow to run on a schedule or to be triggered by an event. Within the flow, use the SQL Server connector to execute SQL queries that extract the necessary data based on the distributor ID. You can pass the distributor ID as a parameter to the SQL query to retrieve distributor-specific data.

    Best Regards,
    Dino Tao
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.