Power BI: Have two input excel files Previous and Current. Would like to track their…
- User
Power BI: Have two input excel files Previous and Current. Would like to track their loaded timestamp each time a new file is loaded. If not new file the Timestamp shall be same as old
- Assistant
To track the loaded timestamp of two input Excel files in Power BI, you can use a combination of Power Query and Power BI's query folding feature. Here are the steps to achieve this:
- Open Power BI Desktop and go to the "Home" tab.
- Click on "Get Data" and select "Excel."
- Browse and select the "Previous" file. Repeat the same process for the "Current" file.
- In the Power Query Editor, select the "Previous" query, go to the "Add Column" tab, and click on "Custom Column."
- In the "Custom Column" dialog box, enter a suitable column name like "Timestamp" and use the following formula to get the current timestamp:
- User
Above not working, better change the logic. Currently i have two files in form of tables "Previous" and "Current"
- Assistant
Apologies for the confusion. If you have two files in the form of tables "Previous" and "Current," you can modify the approach as follows:
- Open Power BI Desktop and go to the "Home" tab.
- Click on "Get Data" and select "Excel."
- Browse and select the "Previous" file. Repeat the same process for the "Current" file.
- In the Power Query Editor, select the "Previous" query. Right-click on the table and select "Advanced Editor."
- In the script window, replace the existing code with the following code:
let Source = Excel.CurrentWorkbook(){[Name="Previous"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Timestamp", each DateTime.LocalNow()) in #"Added Custom"- Click on the "Done" button to close the script window.
- Repeat steps 4-6 for the "Current" query.
- Go to the "Home" tab and click on "Close & Apply" to apply the changes and load the data into Power BI.
This updated approach adds a "Timestamp" column to each table with the current timestamp using the DateTime.LocalNow() function. Every time you load the Excel files into Power BI, the "Timestamp" column will be updated with the new timestamp.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.