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

Replace null values in duplicates

If I have a sorted table like below:

Fruit

Colour

Apple

null

AppleRed
BananaYellow
Pearnull

 

How can I replace the null value in "Colour" with the correct value based on matching values in "Fruit"? The table I would want is:

 

FruitColour
AppleRed
AppleRed
BananaYellow
Pearnull

 

The query I am trying is: 

 

= Table.ReplaceValue(#"Sorted Rows", null, each [Colour]{List.PositionOf([Fruit],[Fruit], 2)},Replacer.ReplaceValue,{"Colour"})

 

but this is not working.

1 ACCEPTED SOLUTION
wdx223_Daniel
Community Champion
Community Champion

= Table.Combine(Table.Group(#"Sorted Rows","Fruit",{"n",each Table.ReplaceValue(_,null,List.Last([Colour]),Replacer.ReplaceValue,{"Colour"})},0)[n])

View solution in original post

1 REPLY 1
wdx223_Daniel
Community Champion
Community Champion

= Table.Combine(Table.Group(#"Sorted Rows","Fruit",{"n",each Table.ReplaceValue(_,null,List.Last([Colour]),Replacer.ReplaceValue,{"Colour"})},0)[n])

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.

Top Solution Authors