Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ZozoeyWang
Regular Visitor

Power BI pick up the latest files in the folder

I am building a data model to present a report have rolling 12 months data. This requires power query always pick up the latest 12 files in the folder. I have used this function before however I am not able to replicate this any more. From memory, you can put the actual number of files in the folder you want power query to load every time you refresh the model, for example, if you want the latest 12 months, you put 12 , if you want latest 24 months, you put 24. Of course, the files would have common name except the date components.

I hope I have made myself clear what I am after. I am not able to find any relevant blogs or videos talk about this. Please can some one give me some directions. Many thanks.

6 REPLIES 6
v-lili6-msft
Community Support
Community Support

hi, @ZozoeyWang

     You may try to use this way:

Step1:

In Edit Queries, Sort by date in descending order

Step2:

add an index column

Step3:

filter the index column like this

9.PNG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Lin,

 

Thanks for your input. 

I've tried both adding index in combine files stage and edit stage. However it didnt work.

 

 

Thanks anyway.

 

Hi @ZozoeyWang

 

 

Can you please share some details about the file names available in the folder.  If you can post some last 6 months files and share it here to work out a solution.

 

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
Ashish_Mathur
Super User
Super User

Hi,

 

Ideally the folder should be having all historical files.  Via DAX formulas, you should be able to compute metrics for rolling 12 months.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

 

Good to see DAX can potentially resolve this, but if I am not mistaken there is a dialogue box for you to overwrite how many files in the file you would like power bi to process/load. And yes the folder would have all the historical files, but I only need the top 12 for example.

 

Thanks

Hi,

 

May be there is a way.  Someone else will help you.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.