The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
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?
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
Suggestions?
Thank you
Solved! Go to Solution.
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}})}))
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}})}))