Dynamicaly set the excel table columns of imported data?

Stelix

New Member
Joined
Aug 25, 2020
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hi all, completely new to power query just started playing with it but I got a question for you if you can help!

So I am trying to import data from a table inside excel A into excel B.

I want the user of excel A to be free to modify their table by moving columns around, renaming them, adding new columns, and removing columns as they are the owner of this file.

now inside excel B i want to make a mirror of the data in excel A by dynamicaly getting its column structure with any changes described above.

googling around I figured out that i can get the source table headers with something like that:

Power Query:
let
    Source = Excel.Workbook(File.Contents("C:\Excel A.xlsx")),
    TBL_Source = Source{[Item="TBL_Source1", Kind="Table"]}[Data],
    GetColumns = Table.ColumnNames(TBL_Source),
    MakeATable = Table.FromList(GetColumns),
    RenamedColumns = Table.RenameColumns(MakeATable, {{"Column1", "ColumnName"}})
in
    RenamedColumns

This gives me something like this

Untitled.png


now my idea was to use the above approach in order to define the column structure inside my actual data query

does that make sense? how can this work in the final query?

could what i need be achieved in a different perhaps easier way?

thx!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,223,268
Messages
6,171,099
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top