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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
clqLoveSpace
Advocate II
Advocate II

End User ability to change SQL query parameters

Hi All

 

One of the few things I liked about using Microsoft Query back in the day was the ability to put a ? in a query that could reference a cell value to accept a user-defined parameter into the SQL. This was really useful when creating reports where the end-user would need to be able to fine-tune a query without SQL knowledge or intervention from someone with SQL knowledge. Unfortunately this was not possible if you wanted to pull data through Power Query.

 

My question is, is it possible to set this up in Power BI Desktop (or not, since it's based on Power Query)?

 

E.g. I have a query that loops over a range of dates, increasing by 1 day per increment. Currently those dates are set to take the start of the previous and current month as the start and end points, but I want it to be possible for the end user viewing the report to define those dates, then refresh. Is this a feature or is this something that I will have to accept can only be done by changing the SQL?

5 REPLIES 5
rashamohsen
Frequent Visitor

Hallo

I have always woundered why I can not do that, I thought it was something I didi not learn.
I would say it is a disadvantage of Power BI, it would help to has the ability to use parameters in the query and make them available for the end users.
Would you please let me know when you find the solution

Best Regards

TomMartens
Super User
Super User

Hey @clqLoveSpace 

 

to some extent this can be achieved using query parameters:

https://docs.microsoft.com/en-us/power-query/power-query-query-parameters

 

But you have to be aware that this will only work, when the user(s) has access to the Power BI desktop file, as soon as the pbix gets published there will be (and also should) be one dataset that is shared between your users. Whenever a user changes the parameter values, that data will change and all other users will be affected.

 

Hopefully this provides you with some additional ideas.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi Tom, I would argue that I DO NOT want the same dataset for my users as different users have different authorizations to see different data. We should be able to define SQL parameters in a Direct Query (based on USERNAME()) which,  today we can't do as far as I know.

Hi Tom

 

Thanks for responding - that's useful to know but it being only available for the end user to change the parameters via desktop isn't ideal, not fussed about the dataset being changed since it will only be used by the end user and our finance team who will both know to check the parameters on every refresh. The idea is we keep one for scheduled refresh with the current/previous month as described before and a separate one that they can alter to view historical data, only refreshing on demand.

 

However this makes it easier for our guys in finance to customize the parameters on behalf of our end users at least so it is still helpful to know.

Mariusz
Community Champion
Community Champion

Hi @clqLoveSpace 

 

Please refer to the video link below, where Patric explains how to achieve this.

https://www.youtube.com/watch?v=7TfV8qTUyfU

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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