Forum Discussion
Anonymous
3 years agoNot applicable
Filter aggregated table with direct query datasource
Hi, I have a report built on a direct query data source. This report contains a table with products and a measure, let's say sales. This table can become very long with hundreds of products. How...
ToddChitt
Super User
3 years agoIf you are doing Direct Query, you should probably write your own SQL statement that does the GROUP BY and a HAVING clause.
Question: Do you need the details of all sales, or just the summary? If you need details, consider wrapping it all in a stored procedure that takes as its input the 'less than threshold' value. (Hint: look at WINDOWING function in T-SQL as they will allow you to get an aggregate of a group for every detail record.)
Use the Advanced Options when setting up your data source. Put in:
EXEC dbo.MyProcedure 100
Then inspect the Power Query code it generated.
Add a Power Query parameter.
Hack the dataset to substitute the literal "100" with the Power Query parameter.