# PowerQuery - How to Add Combine SourceName ?



## OlaSa (Jun 25, 2016)

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.


----------



## anvg (Jun 25, 2016)

Hi


> And want to add a Custom column with the name of origin - where they come from


Try with

```
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,


----------



## OlaSa (Jul 3, 2016)

The solution works perfect, thanks. 
Working on the 2nd suggestion.
//Ola


----------



## OlaSa (Jul 3, 2016)

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.


----------

