# Dynamic source file name change in PowerQuery



## albertan (Jul 27, 2021)

Hello, I appreciate some advice here. 
I have a connection with another csv file but its sheet's name changes every day after it gets replaced with a new extracted file. The sheet name is in this format Data20210721 and it keeps changing every day. So next day it will be Data20210722 after a new extract was done (same folder location) and the old extract will be removed.
Is there a way for me to make it dynamic to a source sheet (the file name doesn't change as well as location) which keeps on changing?


----------



## Alex Blakenburg (Jul 27, 2021)

I quite like @GraH 's suggested solution here:
It may work for you 

Power Query Refresh Prompt To Select File



GraH said:


> Alternative is to filter on latest file on the column creation date. No need to sort first.


----------



## alansidman (Jul 27, 2021)

crosspost:  Dynamic source file name change in PowerQuery


----------



## Alex Blakenburg (Jul 27, 2021)

alansidman said:


> crosspost:  Dynamic source file name change in PowerQuery



Thanks @alansidman, did they post any interesting options. I have not joined that forum and unlike some others it gives you zero visibility.


----------



## alansidman (Jul 27, 2021)

Nothing had been posted.  Same request as here.


----------



## albertan (Jul 27, 2021)

alansidman said:


> Nothing had been posted.  Same request as here.


I mentioned in the other forum that I posted on this forum for a full disclosure, FYI


----------



## albertan (Jul 27, 2021)

Alex Blakenburg said:


> I quite like @GraH 's suggested solution here:
> It may work for you
> 
> Power Query Refresh Prompt To Select File


I figured the way to do it. Used today's formula and concatenated it with another portion that I drill downed and used as a "filepath" which replaced the original path


----------



## GraH (Jul 28, 2021)

Simply read from the folder, select latest file via the filter.  Since it is a date/time column it supports time intelligence.  No need for formula and filepath constructions.
@Alex Blakenburg , thanks for the mention


----------



## albertan (Jul 28, 2021)

GraH said:


> Simply read from the folder, select latest file via the filter.  Since it is a date/time column it supports time intelligence.  No need for formula and filepath constructions.
> @Alex Blakenburg , thanks for the mention


I think you mis understood, because the file keeps changing every month when it comes to sheet name. Anyway, I got problem solved. Thanks


----------



## GraH (Jul 28, 2021)

Good you have a solution ?.

To be frank, I think you misunderstood...   

It's a .csv, so it does not have a sheet name, only a filename. You construct that filename based on today's date, with a formula. I suggest to read from folder, then select the last file.  Regardless of its' name it will get selected.











Where I started with this list




In your example there is going to be only 1 file, since the old ones get removed automatically.
Obviously you choose what you think is best.


----------

