Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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.

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

1 Reply

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

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