Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Replace null(s) in a list

I’m new to M language and I need help regarding converting JSON data using Power Query. As a whole, the process is working however when a “null” is encountered such as shown in the “list” view below,...
  • bluedatenbrian's avatar
    bluedatenbrian
    6 years ago

    Hi!

     

    The only replacement needed in your situation is {null, "NA"}, without quotes on null, and that's why your first code works and the second one doesn't.

     

    Your function should work properly this way:

    (others as list) =>

    let

         listA = List.ReplaceMatchingItems(others, {{null, "NA"}})

    in

        listA

     

    I'm glad I could help you. See ya.

  • v-juanli-msft's avatar
    v-juanli-msft
    6 years ago

    Hi Anonymous 

    Because in Power query, null means null value type, "null" mean a text field which its value is "null".

    In your example, your data example show null value type, so the query with {{"null", "NA"}} doesn't work.

     

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.