Power Query – Source Reference as File Path in Cell
Last Updated :
13 Jun, 2023
Power query helps in doing automation in an efficient manner. It allows users to utilize files stored in specific locations and apply routine transformation steps on those files. It allows users to embed file paths and file sources in an Excel cell. The end user can make use of named ranges and Excel cells as references to access multiple files. In this article, we will learn how to refer to Source as a file path in a cell.
Adding Source Reference as File Path in Cell
Let us take a basic example of how to make use of Excel cells in manipulating file paths. Below is an example where 2 Excel files are there, Power query1.xlsx and Power query2.xlsx.
The reference to source as file path, is only valid if the excel files, have same table name, and same number of columns in it. For example, Power query1.xlsx and Power query2.xlsx, has same table name(Table_src) and same number of columns.
Step 1: In the above example, Excel cells B2 and B3 contain the path of the Excel file. Let us bring the data to be used for transformation.
The name of cell B2, should be replaced with FileP, as shown in the image below. FileP will be the name range cell of B2.
Step 2: To do this, go to the Data ribbon, and click on Get data. Select the option From file and select from Excel/workbook.
Step 3: Select the Python editor1.xlsx from your pc. Select the transform data option.
Step 4: In the query editor, go to the view tab, and select Advanced editor.
Step 5: It shows the code for the Advanced Editor.
Step 6: Change the Code from the above code to this code. The only difference between the two codes is that we have replaced the path, with the name range of that cell.
let
Source = Excel.CurrentWorkbook(){[Name="FileP"]}[Content],
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"D:\gog\Power query 2.xlsx", type any}})
in
#"Changed Type"
Step 7: The Data of Power query1.xlsx is shown below.
Step 8: Now, cell B2(FileP), can show the data of any Excel file. For example, if the path of cell B2, is changed from Power query1.xlsx to Power query2.xlsx. Then, click on the Refresh All button.
Step 9: The data of Power query2.xlsx is shown below.
Similar Reads
How to Create a Relative File Path with Power Query in Excel? In today's digital environment, sharing Excel files effectively is vital. A common issue is that Excel's Power Query uses absolute file paths, which can break when files are opened on different systems. To enhance portability and maintain data connections, it's crucial to convert these absolute path
9 min read
Mixed Cell References in MS Excel Cell: The row and column in Excel together make a cell. We input the value/data(s) in cells of a spreadsheet. There are three types of values that can be entered into the cell. NumbersAlphabeticFormulas Cell reference ââââââis the address or name of a cell or a range of cell is known as Cell referen
3 min read
Absolute References in Excel Macros Excel Macros are incredibly powerful tools that provide the capability to automate repetitive tasks, streamline processes, and save time. When building macros, it's common to use cell references for performing calculations or actions. In some situations, it's important to ensure that these reference
5 min read
Relative, Absolute and Mixed Cell Reference in Excel Understanding how cell references in Excel work is a cornerstone of effective spreadsheet use. Whether youâre building formulas that auto-adjust to changes, locking a specific cell, or creating dynamic worksheets, the types of cell referencesârelative, absolute, and mixedâplay a vital role. This gui
11 min read
Master Power Query Excel in 2024: Step-by-Step Tutorial Mastering Power Query in Excel unlocks a powerful suite of tools for data transformation and analysis, enabling users to streamline their workflows and enhance productivity. As a feature integrated into Microsoft Excel, Power Query simplifies the process of importing, cleaning, and transforming data
15 min read
Power BI - Rename a Dataset in Workspace In this article, we will learn how to a rename data set, in a workspace in Power BI. What is a Workspace? A workspace can be considered a container, where everything related to a report is stored. For example, the data set, report, dashboard, workbook, and its pages. Following are the steps to open
2 min read
How to read password protected excel file in R ? In this article, we are going to see how to read password-protected Excel files in R programming language. File in use:Â file Method 1: Using excel.link Package. Here we will use excel.link package to read the file with a password. Installation: install.packages("excel.link") xl.read.file() function
2 min read
Relative References in Excel Macros We have two options to refer a cell in Excel VBA Absolute references and Relative references. Â Default Excel records macro in Absolute mode. In this article, we learn about Relative references in Excel VBA. Â We select a cell âA1â, turn on âUse Relative Referenceâ and record a macro to type some text
5 min read
Text Modifications with Power Query in Excel In Excel, Power Query is a business intelligence tool that is used to analyze the data imported from different sources. With the help of power query, we can easily clean, transform and reshape our data as per requirement along the way of analyzing the data. In this example, we will learn about the T
5 min read
Power Query Editor in Power BI Power Query Editor is a tool in Power BI Desktop used for data transformation and preparation. It allow to connect, shape and transform multiple data sources according to the user's needs. After making the desired changes the transformed data is then loaded to the Power BI desktop to fetch final out
7 min read