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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors