cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ggernes New Member
New Member

Having many options for a column name to go into the same column

Basically I am trying to import a folder of files.  These files have different header names, but the different header names represent the same data.  So for instance, I want to write something in the advanced editor that takes data from either column "abc" or "xyz" and places it into "Company Code". 

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Having many options for a column name to go into the same column

Hi @ggernes 

When using Folder connector, the column names need to be same so the final table can show as expected.

The easiest way is to change the column name in your souce file.

 

A workaround to change the column name in Power Query is as below:

If file 1 and file 2 have the same structure, columns are corresponding in order.

file 1

abc v
a 1
b 2
c 3
e 4
t 5

file 2

xyz l
1 11
2 12
3 13
4 14
5 15

 

Then we can use the following code to combine two tables.

then change the "column1", "column 2" to your expected names.

Capture4.JPG

let
Source = List.Transform(Folder.Files("C:\Users\maggiel\Desktop\case\8\8.21\di name")[Content], each Excel.Workbook(_)[Data]),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each Table.Skip([Column1]{0},1)),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column1"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Column1", "Column2"}, {"Column1", "Column2"})
in
#"Expanded Custom"

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Community Support Team
Community Support Team

Re: Having many options for a column name to go into the same column

Hi @ggernes 

When using Folder connector, the column names need to be same so the final table can show as expected.

The easiest way is to change the column name in your souce file.

 

A workaround to change the column name in Power Query is as below:

If file 1 and file 2 have the same structure, columns are corresponding in order.

file 1

abc v
a 1
b 2
c 3
e 4
t 5

file 2

xyz l
1 11
2 12
3 13
4 14
5 15

 

Then we can use the following code to combine two tables.

then change the "column1", "column 2" to your expected names.

Capture4.JPG

let
Source = List.Transform(Folder.Files("C:\Users\maggiel\Desktop\case\8\8.21\di name")[Content], each Excel.Workbook(_)[Data]),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each Table.Skip([Column1]{0},1)),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column1"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Column1", "Column2"}, {"Column1", "Column2"})
in
#"Expanded Custom"

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors