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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
OneWithQuestion
Post Prodigy
Post Prodigy

Copy value from one column header to another?

I have this Excel file that we get from a 3rd party.   

We have no ability to modify the file layout itself.

 

The issue is that the Excel file uses dual level headers, the top level is only populated for the first column and the following columns are blank.
B2 has the header, but C2 is blank.  This continues in the same pattern for about 250 columns in width.

OneWithQuestion_0-1668021023146.png

I was going to pivot everything into rows but I'm not sure how to deal with the empty "second" column.
I want to just make it equal to the first.
So B2 has a value, I want C2 to be the same, D2 has a value and I want E2 to be the same value.  All the way down the list for ~250 some columns worth.

How can I accomplish this?

OneWithQuestion_1-1668021255550.png

 



Adding new derived columns would seem to require me to add a very large number of them, I was hoping there was some sort of logic I could use in Power Query that says "if Row 2 is blank look one column to the left"?
All the rows under 2 are "normal" so it's just that row 2 column issue.

Or if I could "collapse" the columns" into prefixes for the next row down

OneWithQuestion_2-1668021349489.png

 



Suggestions?

Thank you

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

firstly, import your file into Source without headers. ie, the columnnames will be "column 1","column2",.....

secondly, click the "fx", left of the formula editor bar

then use these code into the formula area.

=let a=List.Skip(Table.ColumnNames(Source)) in Table.RenameColumns(Source,List.Zip({a,List.Accumulate(List.Skip(List.Zip(List.FirstN(Table.ToRows(Source),2))),{{},null},(x,y)=>{x{0}&{Text.Combine({y{0}??x{1},y{1}},"-")},y{0}??x{1}})}))

View solution in original post

1 REPLY 1
wdx223_Daniel
Super User
Super User

firstly, import your file into Source without headers. ie, the columnnames will be "column 1","column2",.....

secondly, click the "fx", left of the formula editor bar

then use these code into the formula area.

=let a=List.Skip(Table.ColumnNames(Source)) in Table.RenameColumns(Source,List.Zip({a,List.Accumulate(List.Skip(List.Zip(List.FirstN(Table.ToRows(Source),2))),{{},null},(x,y)=>{x{0}&{Text.Combine({y{0}??x{1},y{1}},"-")},y{0}??x{1}})}))

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.