Forum Discussion
How to replace some NULL values by text values from another column in the same rows
Hi lcmbany
If I've understood correctly, you want to replace each null Category Name value with the Product Name value in the same row.
Here's an example:
let
Source = #table(
type table [Product Name = text, Category Name = text],
{
{"Levi's 501 jeans", "Apparel"},
{"Toyota Corolla", "Automotive"},
{"iPhone 12", "Electronics"},
{"Chevrolet Cruze", null},
{"iPhone 14", null}
}
),
#"Replace null Category Names" = Table.ReplaceValue(
Source,
null,
(_) as text => [Product Name],
Replacer.ReplaceValue,
{"Category Name"}
)
in
#"Replace null Category Names"
Does this work as expected?
Hi OwenAuger
Sorry for my silent, was very busy at work!
I tried your code, but got result error.
Same as my firt answer to Omid_Motamedise, maybe I wasn't clear. Let me tell you what I need :
| ID | Product Name | Category Name | Customer Name |
| 1 | Pepsi Cola | Beverages | Yannick |
| 2 | Honda Civic | Automotive | Oliver |
| 3 | Zara clothing | Apparel | Kurt |
| 4 | Rolex watches | Accessories/Jewelry | Joel |
| 5 | Bose headphones | Electronics | Isabelle |
| 6 | Levi's 501 jeans | null | Emerode |
| 7 | Toyota Corolla | null | Noah |
| 8 | Pepsi Cola | null | Albert |
| 9 | PlayStation 5 | null | Sisca |
| 10 | Honda Civic | null | Jessy |
| 11 | Starbucks Coffee | null | Metthew |
I need for each "null" value takes a valid and good category name.
How to do this?
For example :
Row 1 Pepsi Cola = Berevages. But for the same product at the Row 8 = null?
Row 2 Honda Civic = Automobile. But at the Row 7, Toyota Corolla = null?
Row 9, we know that the PlayStation 5 element is on the Electronics category, same as Bose headphones. But on this row, we see null.
I'm wondering how to make sure that each "null" value is replaced with the correct category of each product in the "null" row?