Forum Discussion
Limit Dimension Data based on Fact Table in Power Query
- 4 years ago
Ok. Your current query setup won't allow query folding.
Can you try connecting without using an explicit SQL statement please?
Connect to the DB again, and leave the SQL statement blank:
Just hit OK, then select your dim_employee table from the table list and import.
Assuming this goes as planned, select the [EMPNO] column in your new dimension table and filter just one value. This should be fast to implement and sets us up a new step with the correct structure.
Edit that new step in the formula bar, so it uses our streaming list filter, something like this:
= Table.SelectRows( previousStepName, each List.Contains( List.Buffer( factTableName[EMPNO] ), [EMPNO] ) )This setup should allow PQ to stream the [EMPNO] values from your Excel source into the SQL native query sent to the SQL source for your dim_employee table.
Pete
- 4 years ago
Hi Anonymous ,
If you right-click your #"Filtered Rows" step, is 'Native Query' now selectable, or is it still greyed-out?
If it's still greyed out, try changing one of the column data types to the same type, but not a text column. For example, change a date type column to date type, or a decimal type column to decimal. This is purely to force PQ to re-evaluate the query and hopefully force it to generate a native query to source.
If native query IS selectable, then you're probably at the limit of optimisation. The Oracle Data Access Client (ODAC) requirement isn't the best in this regard.
Pete
Pete
Hi Anonymous ,
Did you try removing the merge and relating in the data model?
I think the fastest setup you'll get to in this scenario would be to use the buffered list filter on the dimension table in PQ, then relate both in the model.
You could also try filtering your dimension table in other ways in PQ before loading. To have 25M employee numbers in a dimension table I have to assume it goes back many years. Is it feasible to filter to maybe only employees active in the last few years? Maybe filter it for certain departments and create separate reports for each department?
This PQ filter will also be included in visual queries sent to the source when using Direct Query.
Pete
Hi BA_Pete
It didn't work.
- BA_Pete4 years agoSuper User
What didn't work? Has it not sped up the process, or did you get an error or something?
Pete
- Anonymous4 years agoNot applicable
Hi BA_Pete
The report works fine based on the established relationship.
But the filter the Dim table based on Buffered list and save the changes steps takes a long time.
- BA_Pete4 years agoSuper User
Hi Anonymous ,
Ok. My guess is that you're applying a query step to your dimension table that is breaking query folding or causing unnecesary processing. Using the method that we have, Power Query should be streaming the F[EMPNO] values to your SQL server in a native query, and should be really fast. Can you right-click the final step in your dimension query and check whether the 'Native Query' option is lit up or greyed-out please?
If it's greyed-out, select your dimension table as we have it set up now, go to the Home tab, select Advanced Editor and copy all the code in there. Then paste the whole lot into a code window here using this button:
Before you close the code window, please just overtype any sensitive connection string values (file paths, server paths etc.) with 'XXX', but keep the code structure itself, as this may be important.
I should be able to see if there's anything breaking query folding or causing unnecessary processing time that we can work around.
Pete