Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
underkar
Frequent Visitor

Add headers to CSV file

Tables.PNG

 

Hi all,

 

I have uploaded a CSV file into my PBI project. As the CSV file has no headers, column names in Table1 are shown as Column1, Column2, Column3, ......, Column100.

 

How can I replace those names for the ones that I have defined in Table2.

 

Many thaks for your help

 

2 ACCEPTED SOLUTIONS

HI @underkar,

 

Based on double check on your snapshot, it seems like your columns are stored in table 2 with original column name and real column name.

 

For your scenario, I modify my formula to use table 2 columns to generate name parameter list which need to be use in table 1.

#"Renamed Columns" = Table.RenameColumns(#"Source",List.Zip({Table2[Column],Table2[Description]}))

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

Thanks Xaoxing!! It works!

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

HI @underkar,

 

You can use List.zip, Table.Renamecolumns and Table.ColumnNames functions to auto rename one table names based other table.

 

Sample:

 

#"Renamed Columns" = Table.RenameColumns(#"Previous Step",List.Zip({Table.ColumnNames(#"Previous Step"),Table.ColumnNames(Sheet2)}))

36.gif

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

 

Hi @v-shex-msft, thanks you very much for your reply.

 

I think this code doesn't work in my example, because I don´t need to replace headers in "table1" with headers in "table2", what I need is to lookup Column1, Column2, etc in "table2" and return the text in column "Description" of "Table".

I hope I have explained this better....

 

#"Renamed Columns" = Table.RenameColumns(#"Source",List.Zip({Table.ColumnNames(#"Source"),Table.ColumnNames(Table2)}))

 

Many thanks

HI @underkar,

 

Based on double check on your snapshot, it seems like your columns are stored in table 2 with original column name and real column name.

 

For your scenario, I modify my formula to use table 2 columns to generate name parameter list which need to be use in table 1.

#"Renamed Columns" = Table.RenameColumns(#"Source",List.Zip({Table2[Column],Table2[Description]}))

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks Xaoxing!! It works!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.