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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.