PQ to Create a Query From Another Query

legalhustler

Well-known Member
Joined
Jun 5, 2014
Messages
1,214
Office Version
  1. 365
Platform
  1. Windows
I have a query that combines two Excel files from a folder. Within the two files there is a Fiscal Year (2016, 2017) column. I would like to know how I can create a second query based on the first query that separate the files by Fiscal Year. If a new Excel file get's added to the folder with a column for Fiscal Year 2018. Then the second query should be able to create another query based on the 2018 Fiscal Year records when I click the refresh button.

Any advice is appreciated.

Thanks!
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Based on some research, I found that you can REFERENCE a query by right clicking it and selecting "Reference"; however, it's not exactly what I want, because from Query1 I would like to create separate queries extracted based on the fiscal year column of Query1. I would like a query for 2016, 2017, 2018 etc and whenever I refresh my workbook it should automatically generate a query for any new fiscal year.
 
Last edited:
Upvote 0
Here is a visual way of looking at my issue:

Query1 has the following columns: | Fiscal Year | B | C | D | E | F | G |

Under Fiscal Year there are records for 2016 and 2017.

I would like the Query Editor to automatically generate queries that creates table for all 2016 records and another query for 2017 records whenever I refresh the workbook. Is this possible?

The end result is having Query1 (as the combined file) and two additional queries like below:

| 2016 | B | C | D | E | F | G |


| 2017 | B | C | D | E | F | G |
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top