I'm tracing my PBI queries against my SQL server and for the life of me, I can't tell why it downloads top 4096 rows from every included data table, only to perform my actual query moments later?
This SQL:BatchCompleted happens:
select top 4096 [$Ordered].[Id], [$Ordered].[CenterId], [$Ordered].[BusinessDate], [$Ordered].[IDCash], [$Ordered].[CashDrawerName], [$Ordered].[OpenTime], [$Ordered].[OpenUser], [$Ordered].[CloseTime], [$Ordered].[CloseUser], [$Ordered].[ReportAmount], [$Ordered].[Shift_Id] from ( select [Id], [CenterId], [BusinessDate], [IDCash], [CashDrawerName], [OpenTime], [OpenUser], [CloseTime], [CloseUser], [ReportAmount], [Shift_Id] from [dbo].[CashTurns] as [$Table] ) as [$Ordered] order by [$Ordered].[Id]
Then a few events later, I see my actual query, SQL:BatchCompleted:
execute sp_executesql N'select [_].[Id] as [Id],
[_].[CenterId] as [CenterId],
[_].[BusinessDate] as [BusinessDate],
[_].[IDCash] as [IDCash],
[_].[CashDrawerName] as [Drawer Name],
[_].[OpenTime] as [Open Time],
[_].[OpenUser] as [Open User],
[_].[CloseTime] as [Close Time],
[_].[CloseUser] as [Close User],
[_].[ReportAmount] as [Amount],
[_].[Shift_Id] as [Shift_Id]
from [dbo].[CashTurns] as [$Table]
) as [_]
where [_].[BusinessDate] = convert(datetime2, ''2018-06-04 00:00:00'') and [_].[CenterId] = 2'
Can you check whether you have given Keep Top Rows as 4096 in Query Editor?
Check this in Query Editor -> Home Tab -> Keep Rows-> Keep Top Rows. If any values mentioned theer, remove that and check again.
I have no "Keep Rows" in my query (well, when clicked from the Query ribbon).
For all data tables (this is SQL BTW), I have some:
and an advanced filter (which I guess is technically a "Keep rows...") with two simple equality comparisons, neither are "top."
could that be preview that PowerBI generates when editing the queries? If so maybe disabling background previews download would help.
or does that happen during regular refresh?
Background refresh is off, and this happens for every refresh (or initial load from a template). My SQL server is unnecessarily interrogated for > 4000 rows, for every table, just prior to performing the actual query, which seems quote incorrect...
I tried recreating the issue by slowly rebuilding my report.
When I add a filter on a date or date/time column with a literal value, it works as expected.
When I instead use a date or date/time parameter as the value for the filter on my date or date/time column, it ALWAYS retrieves 4096 rows, then actually performs the query.
I tried the same thing with a Decimal (int) type filter/parameter combination and there were no issues. It immediately queried the correct number of rows (not first 4906)...
I tried to open an "issue" (hoping that means "bug report") http://community.powerbi.com/t5/Issues/Using-a-date-or-date-time-parameter-as-a-filter-always-result...
I believe this is an actual Issue. Further commentary will be at http://community.powerbi.com/t5/Issues/Using-a-date-or-date-time-parameter-as-a-filter-always-result...