Forum Discussion

JMSNYC's avatar
JMSNYC
Icon for Helper III rankHelper III
7 years ago
Solved

Import files with different files names - Change dynamically files names

Hi,

 

I read some of your solutions to address the changes of files names in PowerBI, but I cannot transpose any of them to my own issues. Could you please help ? 

 

1/ File Name

 

 

The file is replaced each month by a new file whose suffix (yyyymm) changes. Hence, I have to update manually my code for the new posted file to be recognized. How can I avoid that ?

 

2/ Excel Sheet Name. In this example, the name of the source file stays the same, but the Sheet name changes for each new file that crushes the previous one. Hence, I have to change manually the code at these 3 different spots. Can it be automatically updated, whatever the Sheet name is ?

 

 

Thank you so much in advance for any help.

 

  • You can leave that as it is. It's just a variable name (now) and has no connection to your actual data.

     

7 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Going to refer you to ImkeF on this one but a couple of thoughts. 

     

    You could solve this using parameters, that would prevent you from having to update your code.

     

    In the first case, you could probably calculate out the next file by doing something around grabbing the current date and time.

     

    For the second case, I believe that there is a way to grab a sheet by it's "order" instead of its name. There is a way to return the tables (sheets) in an Excel Workbook, https://docs.microsoft.com/en-us/powerquery-m/excel-currentworkbook