Forum Discussion
Using List.Contains causing long load time
Ok...let me see if I can explain this and get some help.
I've got static data in an external excel sheet.
I've loaded that into power query, then Transformed a column to Convert to List and named it "InServiceXIDs_List"
I've then gone through multiple tables, and used "... each (List.Contains(InServiceXIDs_List,[unit_id])=true))" to filter "unit_id" according to the list.
I've also used two of my tables to create a Merge Queries as New. In the new merged queries I do not filter the data because it's already been filtered by the tables that merge being filtered...if that makes sense.
Everything is working, but when I Close & Apply it takes a very long time, 20 minutes or so, to load that data!
Can anyone explain as to why? Is the List.Contains going through each row and does that have to process from the excel sheet? I ask that because when I watch the Refresh window load it says the name of the excel sheet for each of the tables where I've used that List.Contains function.
So, does it go through each row, filtering the unit_id, then process that through and to the merged querie on each row!?! That would be extremely time intensive regarding the amount of data it would be parsing/filtering.
Thanks.
In each table/query where you use the list, add a step up front that buffers your list with
BufferedList = List.Buffer(InServiceXIDs)
Then use BufferedList in place of InServiceXIDs in your later query step(s). Also, you don't need to have "=true" after List.Contains.
Pat
- Anonymous3 years ago
Try this:
(List.Contains(List.Buffer(InServiceXIDs_List),[unit_id])=true))"
--Nate
5 Replies
- ppm1Solution Sage
In each table/query where you use the list, add a step up front that buffers your list with
BufferedList = List.Buffer(InServiceXIDs)
Then use BufferedList in place of InServiceXIDs in your later query step(s). Also, you don't need to have "=true" after List.Contains.
Pat
- CourtsheagrahamRegular Visitor
Thank you for the info and feedback. I need to start doing exactly what you've done here with using the defined variables. I've not turned that to a habbit yet! And I was wondering about using "true", wasn't sure that I needed it, but the tutorial I referenced had it, so here I am! haa. Thanks again.
- ChukaUdehFrequent Visitor
worked like magic, thanks
- AnonymousNot applicable
Try this:
(List.Contains(List.Buffer(InServiceXIDs_List),[unit_id])=true))"
--Nate
- CourtsheagrahamRegular Visitor
Thank you for the information! Seems to be working, about to run it through a similar report and see what the results there are. Thanks again.