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
Christianvs
Helper II
Helper II

Dynamic SQL for a template

Hi

 

I have a template for a report where I have the following issue:

 

The report consist of several queries that all depend on the same variables being present ind the database, i.e.

SELECT ...

FROM ...

WHERE VAR1 = A AND VAR2 = B

 

Every time I make a new report using the template I have to go into every single query and change VAR1 = A and VAR2 = B. Is it instead possible to set A and B to a value from outside the query? Maybe by making a simple table where i set REF1 = A and REF2 = B and then reference this from within the queries with VAR1 = table[REF1] and VAR2 = table[REF2]? In that way i would only have to change the table reference whenever I make a new version from the template.

 

Thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User
2 REPLIES 2
amitchandak
Super User
Super User

Thanks for the answer amitchandak!

This seems to be just the thing I was looking for

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.