locked
Replace values problem RRS feed

  • Question

  • Hi,

    I'd like to replace a set of values in column (B) but only for a specific category in column (A), the rest of the occurrences in column (B) should remain.

    How do I write this in power query?

    Best,
    Khizer

    Thursday, January 23, 2020 11:17 AM

Answers

  • Hi Khizer,

    This site contains tons of solutions +/- easy to adapt, you just have to Search… For example, adapted  How do i replace specific values in a column? (there are others) does what you want

    When [A] = 1 I want to replace [B] with "foo", otherwise keep [B]:

    let
        Source = ...,
        Replaced = Table.ReplaceValue(Source, each [B], each
            if ([A] = 1) then "foo" else [B],
            Replacer.ReplaceValue, {"B"}
        )
    in
        Replaced

    Thursday, January 23, 2020 11:43 AM