Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
rnola16
Advocate II
Advocate II

Dynamic M Query Parameters - Custom Value

Hi,

 

SQL:

Select

A.EMP_ID, A.NAME

From EMP A

where A.EMP_ID = 'Parameter1'

 

Here the EMP table has got billion records. I have a direct query with the custom SQL included and tried to parameterize the query on EMP_ID. How can we use dynamic M query parameters on EMP_ID so users can input their choice of 'EMP_ID' in the parameters. ?

If the table was small I would inlude all values and define on a new table and bind that to parameter but how do you work with huge tables ?

 

Thanks.

1 ACCEPTED SOLUTION
Deku
Super User
Super User

if the users already know the id they can pass arbitrary values without having to define a lookup list

.https://blog.crossjoin.co.uk/2023/01/29/passing-any-arbitrary-value-from-a-power-bi-report-to-a-dyna... 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

4 REPLIES 4
Deku
Super User
Super User

if the users already know the id they can pass arbitrary values without having to define a lookup list

.https://blog.crossjoin.co.uk/2023/01/29/passing-any-arbitrary-value-from-a-power-bi-report-to-a-dyna... 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

I owe you a lunch. Thanks.

Akash_Varuna
Super User
Super User

Hi @rnola16 Could you try this please for Dynamic Query Parametrs
Create a parameter (`Selected_EMP_ID`) and reference it in the SQL query within Power Query to filter dynamically. Use a text box or slicer in the report for user input. Ensure query folding works and the `EMP` table has an index on `EMP_ID` for performance.
Please Check the following power query

 

let
    Source = Sql.Database("YourServer", "YourDatabase", [Query = "SELECT A.EMP_ID, A.NAME FROM EMP A WHERE A.EMP_ID = '" & Selected_EMP_ID & "'"])
in
    Source

 

 

This was my initial try, but here the query would do two iterations. 1. Bring all the EMP_ID 2. Run for the EMP_ID selected. Not efficient. 

 

Thanks.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.