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.
Hello everyone,
I have SQL datasource and fetching just one table.
I want to apply Incremental Refresh on the table. Hence, I created 2 parameters - RangeStart & RangeEnd and also both, parameters and the date field both have Date/Time as datatype.
So, when I do all the transformations, I am able to see 'View Native Query' as enabled. As soon as I filter the field with these parameters, it becomes disabled.
So I tried following alternatives:
Does anyone have faced this issue or can guide me through it?
Any help would be great.
Thanks in advance.
Hi @rajulshah ,
what kind of database is your data source? (MS SQL?)
To me the "Native Query" is more of an indicator, can you check on the database what query Power BI is really sending?
Hello @mwegener , thank you for the response.
Yes, the query sent to SQL Server has this filter applied, then also it would load all the data in Power BI and then filter it in there.
Hi @rajulshah ,
if the filters are present in the SQL query, the query folding will also work and only the data that is needed will be transferred from SQL Server to Power BI.
Yes, but what it does is loads all the rows in the Power BI, let's say 10 million and then applies filter to it and in the end, the table will have only filtered rows, i.e 2 million rows.
do you know why it does this?
When Power BI loads all rows, the filter is not in the WHERE clause of the SQL.
Can you post screenshots of the Power Query Steps and the SQL.
Sure,
Below are the steps of our query:
But instead of the parameters, even if we use hardcoded numbers, it loads all the data and then filters in Power BI. Also, I have used view, but the native query does not have the filter conditions in it.
Am I doing anything wrong? Please guide.
Hi @rajulshah ,
to my knowledge the "Changed Type" step breaks the query folding. Why does the data type need to be changed here?
Hello @mwegener ,
We are fetching the Date in number format but it is not imported as "Whole Number" but in text format.
Hence, we are changing the formats. Moreover, by clicking on this step, I am able to see "Native Query" but not on the next step.
Hi @rajulshah ,
maybe you can try the following.
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [PurchaseDate] >= Number.FromText(DateTime.ToText(RangeStart, "yyyyMMdd")) and [PurchaseDate] < Number.FromText(DateTime.ToText(RangeEnd, "yyyyMMdd")))
it unsettles me that Power Query doesn't recognize the column's data type correctly, but never mind.
Can you post a screenshot of the SQL statement as Partrick shows it in his video?
Can you post your function ConvetDateToKey?
Hello @mwegener ,
Thank you for the response, and sorry for the late response.
We have already done that using the ConvertDateKey function as shown in Patrick's video.
Do you have any idea whether Query Folding is done in a view or not?
Is there any chance that Query Folding isn't happening because we have used a view?
Hi @rajulshah ,
Query Folding is also executed on a view, as Power Query queries the database object.
At the end of the day, Power Query doesn't care if it has to query a table or a view, since the SQL is the same.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
88 | |
63 |