0
votes

I have two queries created in Power Query that pull data from the same folder and are appended. The reason for this is because that folder contains many files with two distinct data structures, one is an old structure created by someone from the past and the other is a new structure I created.

So how I have the queries running right now is the older data structure query is filtering out (Unchecked) the new structure files and vice-versa with the new data structure query (Filtering out the old data structure files). That way both queries can run their distinct applied steps and load the resulting data from both into 1 table.

The problem I am facing is that when I save a new file in that folder (new file saved weekly) both queries are running their applied steps to the new file resulting in expression errors. So I am forced to go into the query editor and go the the older data structure query, go into the filtered tables step and uncheck the new file, then go into the new data structure query, go into the filtered table step and make sure that the new file is checked in there.

How can I go about automating this in a way where when a new file is saved, the older data structure query will not run it's applied steps but the new data structure query will?

The Two Queries

enter image description here

Filtered Rows Step on the first query showing the old data structure files checked, and the new data structure files unchecked.

enter image description here

Filtered Rows Step on the second Query showing the old data structure files un-checked and the new data structure files checked.

enter image description here

1

1 Answers

0
votes

Assuming all the new files begin with "ELUX" and all the old files don't, then:

To include only old files:

= Table.SelectRows(#"Removed Other Columns1", each not Text.StartsWith([Source.Name], "ELUX"))

To include only new files:

= Table.SelectRows(#"Removed Other Columns1", each Text.StartsWith([Source.Name], "ELUX"))