Forum Discussion
Query Folding dissable after using filter - ODBC - Postgresql Unicode
- 1 year ago
Hi kamilos01 -Yes, the issue you're facing is most likely due to query folding breaking when you apply a filter using RangeStart and RangeEnd in Power Query.
as checked the steps, bfore merging, apply the date filter as early as possible.This ensures filtering happens before merging.If the View Native Query option remains greyed out, then filtering is happening locally. in someways, Instead of merging in Power Query, try joining tables in PostgreSQL first and then importing the result.
Hope the above information helps.
- 1 year ago
Hi rajendraongole1
Thanks for your suggestions. Yes, I was trying to filter out as early as possible (including other columns), but always "View native query" was greyed out.
Initially I wanted to use join in my postgresql DB earlier, but simple table was too big to get it and I always got an error.
hi kamilos01 ,
This is a classic issue with Power BI and ODBC sources like PostgreSQL query folding breaks when Power Query can’t push your filter step down to the database, so it processes everything locally (which is way slower).
Here’s what you can do:
-
Filter as early as possible: Always place your RangeStart/RangeEnd (or any filter) as the first steps in your query before merges or transformations. This gives Power Query the best shot at folding.
-
Check your data types: Make sure both your parameter and the column in PostgreSQL are the same data type (ideally timestamp). Even a small mismatch will break folding.
-
Avoid anything that blocks folding: Steps like Table.Buffer or complex calculated columns can stop folding dead in its tracks. Keep things simple up to your filter step.
-
Try a native SQL query: If folding just won’t work, use a native SQL query inside Power Query (Home > Advanced Editor).
- Update your ODBC driver: Sometimes just using the latest PostgreSQL ODBC driver (or even switching to Npgsql in DirectQuery mode) improves folding support.
- For merges/joins: If possible, do your joins in the database first (using a view or SQL), then pull the result into Power BI, instead of merging in Power Query.
- kamilos011 year agoNew Member
Hi rohit1991,
Thanks for your suggestions. Unfortunately the last one is the right one.
Just after uploading the table, I tried to filter any column (text, numeric, date) but always the "View native query" field got greyed out 😞 Also using select doesn't work.
I'm not using the Table.Buffer function.Maybe using native postgresql is an option.