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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Merged cell

Dear                                                          

 

i have excel table contains Item number, Department and Location having thousands of rows. Department and Location column contains merged cell as shownn:

 

Capture.JPG

 

i need prepare data for power bi, in the format: 

result.JPG

 how can i achieve this above in Power bi/ Excel ??

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

First, you can replace the empty values in excel cells with the special string(For example: NULL) in your source excel file just as below screenshot. Power BI will keep the value for the first row of the merged cell and the rest ones will be null when you load the data with merged cell. So we need to deal with these empty values first in excel file...

yingyinr_0-1649235955845.png

Then we can use Fill down feature in Power Query Editor to fill the values for the "left ones" in merge cell...

Fill downFill down

yingyinr_2-1649236480788.png

The full applied codes as follow:

let
    Source = Excel.Workbook(File.Contents("\your directory\data.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Item number", type text}, {"Department", type text}, {"Location", type text}}),
    #"Filled Down" = Table.FillDown(#"Changed Type1",{"Department"}),
    #"Filled Down1" = Table.FillDown(#"Filled Down",{"Location"}),
    #"Replaced Value" = Table.ReplaceValue(#"Filled Down1","NULL","",Replacer.ReplaceValue,{"Department", "Location"})
in
    #"Replaced Value"

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

First, you can replace the empty values in excel cells with the special string(For example: NULL) in your source excel file just as below screenshot. Power BI will keep the value for the first row of the merged cell and the rest ones will be null when you load the data with merged cell. So we need to deal with these empty values first in excel file...

yingyinr_0-1649235955845.png

Then we can use Fill down feature in Power Query Editor to fill the values for the "left ones" in merge cell...

Fill downFill down

yingyinr_2-1649236480788.png

The full applied codes as follow:

let
    Source = Excel.Workbook(File.Contents("\your directory\data.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Item number", type text}, {"Department", type text}, {"Location", type text}}),
    #"Filled Down" = Table.FillDown(#"Changed Type1",{"Department"}),
    #"Filled Down1" = Table.FillDown(#"Filled Down",{"Location"}),
    #"Replaced Value" = Table.ReplaceValue(#"Filled Down1","NULL","",Replacer.ReplaceValue,{"Department", "Location"})
in
    #"Replaced Value"

Best Regards

rbriga
Impactful Individual
Impactful Individual

To the best of my knowledge (some searching included), you can't do it with escel or Power BI, as tables unmerge those cells.

Some VBA scripts are availble, but your data also contains "legitimate" blanks, so that eliminates that option.

-------------------------
Data analyst by day, hockey goalie by night.
Did I help? Then please hit that "kudos" or "accept as a solution" button!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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