Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

ReplaceValue for multiple columns

Hi guys,

 

I would appreciate some hints on how to solve a problem I'm currently facing. The goal is to replace values for multiple colums dynamically.

 

In case the Column "ACC (Lx)" is null, it should take the value from "ACC (Lx) (v)". 

 

For a single column I do it like this:

= Table.ReplaceValue(#"Converted to Table",null, each [#"ACC (L5) (v)"],Replacer.ReplaceValue,{"ACC (L5)"})

 

Any ideas on how I can make it dynamic for all columns?

 

Thanks

Dan

  • =Table.FromRecords(Table.TransformRows(#"Converted to Table",each let a=Record.ToTable(_) in Record.FromTable(Table.ReplaceValue(a,each [Value],each [Name],(x,y,z)=>x??a{[Name=z&" (v)"]}?[Value]?,{"Value"}))))

2 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    =Table.FromRecords(Table.TransformRows(#"Converted to Table",each let a=Record.ToTable(_) in Record.FromTable(Table.ReplaceValue(a,each [Value],each [Name],(x,y,z)=>x??a{[Name=z&" (v)"]}?[Value]?,{"Value"}))))