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
dmarkie
Frequent Visitor

Fill Adjacent Blank Cells

Hello;

I am trying to transform a table that has a couple of columns similar to below.  There are hundreds of MasterIDs.  Some MasterID have a corresponding VehID however there are some records/rows where the VehID is missing.  How might i fill these blank values with the same VehID value?  I've tried using Fill in various ways but with no luck.  

Thanks in advance

Dave

 

Master IDVeh ID
355225
355 
355255
355 
355 
355 
355 
355225
450 
450210
450 
450210
450210
1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjY1VdJRMjIyVYrVgfGQmEamOCQIMmFGmpgawCQgTCNDA2IkwLxYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Master ID" = _t, #"Veh ID" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Master ID", Int64.Type}, {"Veh ID", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Master ID"}, {{"Temp", each _, type table [Master ID=nullable number, Veh ID=nullable number]}}),
    //Function Start
    fxProcess=(Tbl)=>
        let
            #"Filled Down" = Table.FillDown(Tbl,{"Veh ID"}),
            #"Filled Up" = Table.FillUp(#"Filled Down",{"Veh ID"})
        in
            #"Filled Up",
    //Function ENd
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each fxProcess([Temp])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Master ID", "Temp"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Master ID", "Veh ID"}, {"Master ID", "Veh ID"})
in
    #"Expanded Custom"

 

View solution in original post

2 REPLIES 2
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjY1VdJRMjIyVYrVgfGQmEamOCQIMmFGmpgawCQgTCNDA2IkwLxYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Master ID" = _t, #"Veh ID" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Master ID", Int64.Type}, {"Veh ID", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Master ID"}, {{"Temp", each _, type table [Master ID=nullable number, Veh ID=nullable number]}}),
    //Function Start
    fxProcess=(Tbl)=>
        let
            #"Filled Down" = Table.FillDown(Tbl,{"Veh ID"}),
            #"Filled Up" = Table.FillUp(#"Filled Down",{"Veh ID"})
        in
            #"Filled Up",
    //Function ENd
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each fxProcess([Temp])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Master ID", "Temp"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Master ID", "Veh ID"}, {"Master ID", "Veh ID"})
in
    #"Expanded Custom"

 

Thank you Vijay for your answer.  I was able to sole this vai transforming the data in excel prior to the bi import.

 

Thanks again.

Dave

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Users online (4,055)