Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago

Power bi reports using parameters to create SQL queries and displaying the results.

Hi,

I have drop down lists from imported SQL data tables to choose parameters in Power bi. I would like to place these parameters in a SQL query to query the tables or send the parameters back to SQL to query results and display the results back in Power bi. How is the parameters transaction made into queries of tables and displaying results in power bi?

9 Replies

  • Let em get this straight: You must first load data via the Power Query (queries) before an visuals will render in Power BI report pages. And on those pages you want to have the user be able to select a parameter and THAT changes how the queries behave, that have ALEADY run?

    Did I understand that correctly?

    Can't be done.

    Maybe you can use Parameters in Power Query, where you can inject those values into the individual queries with simple transformation steps like filtering, etc.

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for your reply. I'll try to make it clearer. '...and THAT' meaning those chosen paramters need to be either be used against the imported data from SQL in Power bi, or run a SQL query in the SQL DB, in both cases display the results in Power bi.

  • Sorry, but this did not help me understand what you are trying to do. Can you show us a picture of what this means:

    "I have drop down lists from imported SQL data tables"

    What is in this data? Names of tables? Or actual table data?

    • Anonymous's avatar
      Anonymous
      Not applicable

       Names of tables? Or actual table data? - actual table data

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous 

        You can refer to the solution i offered above, create a dynamic paramater, then use the paramater in sql query, it can return the related result.

         

        Best Regards!

        Yolo Zhu

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

    Thanks for the solution ToddChitt  offered, and i want to offer some more information for user to refer to.

    hello Anonymous , based on your descriotion, you can consider to use dynamic paramater in power query, it can be used in power bi desktop so that can affect the query, but it can be used when the connection mode is direct query. You can refer to the following link about it.

    Dynamic M query parameters in Power BI Desktop - Power BI | Microsoft Learn

    And you can refer to the following sample 

    Pass Parameters to SQL Queries - Excelguru

     

    Best Regards!

    Yolo Zhu

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

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    'You must first load data via the Power Query (queries) before an visuals will render in Power BI' - I loaded SQL tables into Power in a slicer format

    and wish that the state picked will be used as a parameter to query another table that was also loaded in power.

    .