Forum Discussion
How to use Filters in database queries?
Good.
I need to use the From/Until I select the query user in SQL syntax to fetch data.
You could initially run the query to the SQL server by taking the last 30 days as a default search.
But then the user must select other Ranges From/To and I need to take those values to rerun the query to the database with the new date range...
How could I do that?
Best regards
13 Replies
- jstorm
Resolver III
I'm not completely sure what you want to accomplish, but from what I am understanding, you should load all of the data for all dates. Then, use the slicer visual with your dates to select the date range you want to show in your report.
- GustavO65
Helper II
Hello @jstorm
Thank you for your answer..
The problem is that the table on which I should base the query has 2,000,000 records.. When in fact a user's query needs only 5% or 6% of them...
I find it very unreconventional to have to take the 2,000,000 records when maybe I could trigger a much narrower query...
Best regards
- jstorm
Resolver III
I see. Do you have date ranges that users are interested in within a general time range or want users to be able to select any date range from the 2 million records? For example, if the data covers the last 10 years, you could filter to only the last two years, if that's what's relevant to the end user.
Another thing to keep in mind is if you need to use DirectQuery at all. Do I need to report your data in real time or in near real time? If not, you must switch to Import. Your reports will run much better and the number of records will not matter almost as much. It will also significantly reduce the impact on the SQL server.
Consider reviewing this documentation on query types.
https://docs.microsoft.com/en-us/power-bi/desktop-directquery-about