May 26 2022 07:59 PM
Hi, everyone:
I am new to Power Query and not sure why it is taking hours to execute the code below. Because the data is sensitive, I am unable to share the file. However, I can say that the file contains 300K+ records, and the following are the PQ queries I am executing (note: variable names have been modified):
May 26 2022 09:16 PM
@Cindysc1218 It may be difficult to judge, based on the code alone, but it seems that in the second step you add a column with filtered content. If I'm not mistaken, that creates a column with 300K identical tables of filtered records, that you then Expand and Group. Could you not just use two filter steps (i.e. Table.SelectRows) and end with something like this?
Filter1 = Table.SelectRows(#"Orders", each [Ship Date] >= [#"Post Date - 30"] and [Ship Date] <= [#"Post Date + 30"]),
Filter2 = Table.SelectRows(Filter1, each [Acct] = [#"Account No."])
Not being able to test any of this, I may be missing the point altogether.
May 26 2022 09:36 PM
May 26 2022 09:38 PM
May 26 2022 09:49 PM
@Cindysc1218 I'm not suggesting anything, but merely notice that you seem to add a column with identical tables containing filtered records to each of the 300K rows. And I'm just wondering why you don't filter the date column first and then the account number. But as said that's difficult to judge without seeing the data. What stops you from trying on a copy of your file. If it doesn't work, I clearly missed the point.
Or perhaps you could just add a column stating:
= [Ship Date] >= [#"Post Date - 30"] and x[Ship Date] <= [#"Post Date + 30"] and x[#"Acct"] = [#"Account No."]
This should result in TRUE or FALSE. After that, filter TRUE to keep matching rows.
May 26 2022 10:23 PM
May 26 2022 10:27 PM
@Cindysc1218 Can't answer as I'm having a hard time visualizing your data. Sorry.
May 26 2022 11:50 PM