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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
peebes1
New Member

Using SQL to override a parameter built into the data source

My SQL Server database has an optional "fiscal year" parameter.  If no value is chosen at the database level, the default is to return data for only the current fiscal year.  I can't figure out how to use SQL to get Power BI to interact with the parameter and let me choose the fiscal year(s) I want.  If I use a SELECT statment with a WHERE clause for the fiscal year, it is too late, and the database is only sending through current fiscal year data.  In Tableau, I could use the OpenTable command (example below) to take control.  Is there a way I can get Power BI to do this as well?

 

OpenTable("Beneficiary"."Frequently Used Fields",
"Choose one or more Fiscal Years"= "[2023, 2024]"

2 REPLIES 2
v-venuppu
Community Support
Community Support

Hi @peebes1 ,

Thank you for reaching out to Microsoft Fabric Community.

Thank you @Akash_Varuna for the prompt response.

Use a native SQL query in Power BI combined with a parameter that lets users select the fiscal years:

Create a parameter in Power BI to let users pick one or more fiscal years.Use a native SQL query (via "Advanced options" in the SQL Server connector) that includes a placeholder for fiscal year filtering.Edit the M code in Power Query to dynamically insert the selected parameters into the SQL query before it’s sent to the server.Ensure you query a table or custom SQL,not a view/function that already applies default filtering.

 

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

Thank you.

Akash_Varuna
Community Champion
Community Champion

The default behavior of Power BI’s SQL Server connector does not allow you to pass parameters directly into the database query. To address this, create a stored procedure in SQL Server that accepts fiscal years as input and dynamically retrieves data based on the parameter. Use Power BI to execute this stored procedure via DirectQuery and bind it to a parameter in Power BI for user selection.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.