PowerQuery - How to Add Combine SourceName ?

OlaSa

New Member
Joined
Mar 22, 2015
Messages
23
Hi,
I have a formula, that Combines 3 queries ("3 PQ's based on 3 tables in Excel (2013)"):
Source = Table.Combine({Antura, MAB, ProjectCenter}),

And want to add a Custom column with the name of origin - where they come from - Antura/MAB or ProjectCenter.
What's a good way to do this ? - I tried with a Conditional Column (if not null), but it felt a bit dicey.
Ola



Additional info:
I try to combine '3 separate project catalogues' to 'One project catalogue'.
1/3 of the column headers exists in all 3 project catalogues,
1/3 of the column headers exists in all 2 project catalogues,
1/3 of the column headers is unique to one project catalogues.
This means the Total Project Catalogue has as many rows as the 3 project catalogues combined.

If (just if) you also have a suggestion for a ColumnHeader Translation Table...
If ColumnHeaderName is xxx then Change-ColumnHeaderName to yyy....
I would be even happier.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi
And want to add a Custom column with the name of origin - where they come from
Try with
Code:
Source = Table.Combine({
    Table.AddColumn(Antura, "Source Name", each "Antura", type text), 
    Table.AddColumn(MAB, "Source Name", each "MAB", type text), 
    Table.AddColumn(ProjectCenter, "Source Name", each "ProjectCenter", type text)
    })
If (just if) you also have a suggestion for a ColumnHeader Translation Table...
If ColumnHeaderName is xxx then Change-ColumnHeaderName to yyy....
Use before a combine function Table.RenameColumns function.
Regards,
 
Upvote 0
Solved the Dynamic ColumnName after some tweaking of...
//Ola


let
Source1 = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Source2 = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],


rename_list = Table.ToColumns(Table.Transpose(Source2)),
result = Table.RenameColumns(Source1, rename_list, MissingField.Ignore)


in
result


Source:
Post: powerquery - Dynamically rename a set of columns using Power Query - Stack Overflow
Picture https://bondarenkoivan.files.wordpress.com/2015/04/rename-columns-challenge1.png?w=636
+ I recommend Ivan's blog posts - solutions to common problems.
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,003
Members
449,203
Latest member
Daymo66

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