Forum Discussion
How to use Filters in database queries?
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.
- GustavO656 years ago
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
- jstorm6 years ago
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
- GustavO656 years ago
Helper II
Hello @jstorm
In principle I'm trying to use DirectQuery (I have a report armed with "Import" and the data on it is not being updated..)
Users have to select any date range....
It is not extremely important and/or critical that you report the data in real time. I could use "Import".. (I would have to finish viewing/resolving because the consultation I have in the armed office is not refreshing the information when I have created the task on the PoweBI Server to keep it in sync..)
Best regards
- Anonymous6 years agoNot applicable
I assume you're mode you are fetching the data is set to DirectQuery. Is that the case?
If so, then you simply need to set up your visualization along with the date slicer. PowerBI will automatically append your query with the approproate WHERE clause to narrow your query.
Keep in mind that Power BI does have a 1,000,000 row limit on data returned from a database when in DirectQuery mode. It doesn't sound like you will be anywhere close to that.
Also, for performance reasons, make sure your filtered query can return in < 5 seconds.- GustavO656 years ago
Helper II
Hello @jptak
Thank you for your answer..
I'm sando QueryDirect..
How do I do/define this that you tell me? you just need to set up the display along with date segmentation
Apologies but I'm new to PowerBI and I'm trying to migrate my reports made at Reporting Services to use the full power of PowerBI in handling information...
Best regards