Forum Discussion
Anonymous
5 years agoNot applicable
Replace null values in duplicates
If I have a sorted table like below:
| Fruit | Colour |
| Apple | null |
| Apple | Red |
| Banana | Yellow |
| Pear | null |
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:
| Fruit | Colour |
| Apple | Red |
| Apple | Red |
| Banana | Yellow |
| Pear | null |
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_DanielCommunity Champion
= Table.Combine(Table.Group(#"Sorted Rows","Fruit",{"n",each Table.ReplaceValue(_,null,List.Last([Colour]),Replacer.ReplaceValue,{"Colour"})},0)[n])