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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Hsilva
Helper I
Helper I

Merging Columns

Hi Community;

I have an excel report (which comes from MYOB) where some columns have header and others do not. Sometimes the data splits in two columns, so I have to merge these two columns in order to get the 100% of the detail. The problem is that the position of the columns change from one report to another, for example:

 

Report A (total quantity = 15 in two columns)

ItemColumn2Column3 Quantity
Anull10 
Bnull 5

 

Report B (total quantity =15 in one column)

ItemColumn2Quantity
Anull10
Bnull5
   

 

I my first query I did Promote headers, then merge Columns "Quantity" with "Column3" to get the total = 15.

In the second report, I do not need to merge, but when merging I got the error "Column3 wasn't found"

 

Any suggestions would be much appreciated.

Regards

Humberto

3 REPLIES 3
Anonymous
Not applicable

Hi @Hsilva ,

 

Based on this:

In the second report, I do not need to merge, but when merging I got the error "Column3 wasn't found"

 

You may have referenced a no-existing column . So please navigate to the wrong Applied step.

Eyelyn9_0-1648109102967.png

And If possible, please share the whole M syntax to help us clarify your scenario.

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hsilva
Helper I
Helper I

Hi Vijay, thank you very much for your prompt answer.

Apologies I think I made a mistake simplifying the example. The code works if the file has one empty column, however it has many and Ialso applyed few steps to get the header.

If you can have a look to the attached file and give me some advice would be great.

Thank you again for your help.

Humberto

 

https://primaryhealth-my.sharepoint.com/:x:/g/personal/josef_silva_primaryhealthcare_com_au/ERsa24vI... 

Vijay_A_Verma
Super User
Super User

Use following m code for dynamic merging of columns (Solution demonstrating this is uploaded to https://1drv.ms/x/s!Akd5y6ruJhvhuS9iB3OYRgx-5Bjb?e=0CkeKS )

let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    ListOfColumns = List.RemoveFirstN(Table.ColumnNames(Source),1),
    TransformListOfColumns = List.Transform(ListOfColumns, each {_, type text}),
    #"Transform Column Types" = Table.TransformColumnTypes(Source, TransformListOfColumns),
    #"Combine Columns" = Table.CombineColumns(#"Transform Column Types",ListOfColumns,Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Final Quantity"),
    #"Result" = Table.TransformColumnTypes(#"Combine Columns", {"Final Quantity", type number})
in
    Result

 

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