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

Don'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.

Reply
Anonymous
Not applicable

How to append automatically new sheet into the historical table

Hi all,

 

I have the following scenario:

 

1) Every day there is a new sheet saved in the same folder

2) I need to append this sheet into a historical table

 

I am extracting the files using the folder option and sorting the last file saved in the folder to get the last one. However, I'd like to know how can I append automatically this new file automatically into the history table or even better if there is a better option. Maybe using the incremental extraction?  Thanks in advance!

4 REPLIES 4
mussaenda
Super User
Super User

Hi @Anonymous,

 

if you are retrieving the file using folder, 

do not filter it by latest file. retrieve all.

Then after doing ETL, you can refrence the table and filter only to the latest file. (only if you are open to make another table.)

 

If not open to refrence a table,

use dax to retrieve the latest file.

 

Hope this helps. 

Anonymous
Not applicable

Hi @mussaenda ,

 

I didn't get your point, are you refering to this approach shared previouslyt by Amit? 

amitchandak
Super User
Super User

@Anonymous , have you already tried the option in this blog?

https://wkrzywiec.medium.com/getting-data-from-the-latest-file-in-a-folder-using-power-query-51dfa4bff711

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak ,

Thanks for your answer, that would be my approach to get the latest file, however, my question is how to append them automatically in power BI, every day, so can build the a historical table. For example, using power query in Excel it is possible doing the following:

 

1) Create a query extracting the latest file from the folder

2) Copy this query and change the source for the table in excel where you want to keep the historical data:

    As you can see the table in my case is tblAldiDailyScanHist and every day you append the new data

 

 let
Source = Excel.CurrentWorkbook(){[Name="tblAldiDailyScanHist"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Aldi Ref", type text}, {"Product", type text}, {"Qty (Units)", Int64.Type}, {"StartOfWeek(Sun)", type date}}),
#"Appended Query" = Table.Combine({#"Changed Type", qryAldiDailyScanData}),
#"Filtered Rows" = Table.SelectRows(#"Appended Query", each ([Product Code] <> null)),
#"Removed Duplicates" = Table.Distinct(#"Filtered Rows"),
#"Reordered Columns" = Table.ReorderColumns(#"Removed Duplicates",{"Date", "StartOfWeek(Sun)", "Mth#", "Year", "Product Code", "Aldi Ref", "Product", "Brand", "Qty (Units)"}),
#"Sorted Rows" = Table.Sort(#"Reordered Columns",{{"Date", Order.Descending}})
in
#"Sorted Rows"

 

 

However, when I tried in Power BI, I got the following error:

Expression.Error: A cyclic reference was encountered during evaluation.

 

What I can try is to create a empty query with the same structure and try this approach

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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