OpenBI Docs Buy

Replacer.ReplaceValue

Replaces a value when it equals the old one as a whole: the replacer for whole cells.

Group: Splitters, combiners, replacers and comparers. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Replacer.ReplaceValue(value as any, old as any, new as any) as any
ParameterTypeDescription
valueanyThe value to test.
oldanyThe value to look for.
newanyWhat to give instead.

Returns

any. The new value when the value equals the old one; the value itself otherwise.

Remarks

  • It works on any kind of value: numbers, dates, null. Text must match whole: replacing "Oslo" leaves "Oslo City" alone.

Examples

Zeros to null

let
    Stock = #table({"Product", "Stock"}, {{"Chair", 0}, {"Desk", 10}, {"Lamp", 0}})
in
    Table.ReplaceValue(Stock, 0, null, Replacer.ReplaceValue, {"Stock"})
ProductStock
Chairnull
Desk10
Lampnull

Whole values only

let
    Shops = #table({"Shop"}, {{"Oslo"}, {"Oslo City"}})
in
    Table.ReplaceValue(Shops, "Oslo", "OSL", Replacer.ReplaceValue, {"Shop"})
Shop
OSL
Oslo City

Replacer.ReplaceText, Table.ReplaceValue, List.ReplaceValue.

Last updated · OpenBI Studio 0.3.79