Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Scenario:
Each day or Each month, an excel file with new dates’ date will be added. The data structure is the same, only data is different. How to automatically obtain the data of a new file in power bi desktop?
Sample 1: Select the latest data based on the creation date
Files in excel:
Steps in Power Query:
Reference: Combine files (binaries) in Power BI Desktop - Power BI | Microsoft Docs
Sample 2: Select the latest data based on the date in the file name
Files in excel:
Data in PQ:
Operations:
We need to import the table data in the folder into excel first, and custom the code in PQ advanced editor to dynamically obtain the source data, so when refreshing the data, it will automatically find the file with the latest date in the folder.
Step analysis:
As you can see, we need to obtain the data source dynamic and split the second step of the first picture into three smaller steps (picture 2).
First use the temp step to customize the excel file name, which can include a combination of text and date. The date doesn’t have to be selected only today, it can be tomorrow or yesterday, or even a week ago, it depends on your needs.
Example Yesterday: Date.AddDays ( Date.From(DateTime.LocalNow()),-1)
Second match the same name as temp in the general table to get this table.
Third get the content in the table and replace this result in the following ‘import excel’ step.
Finally, click OK to apply to Power Query and get the data of the corresponding date.
Here’s the final result:
Summary: According to different needs, we can use different methods to flexibly obtain Excel file data of different dates.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.