Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

ReplaceValue in List.Accumulate

Hello, everyone,

 

I have problem with my PowerQuery code.

 

The purpose of the line is to replace space in all rows of each column.

 

The line is:

#"Replaced Value" = List.Accumulate(Table.ColumnNames(#"PreviousTable"), null, (state, current) => Table.ReplaceValue(#"PreviousTable"," ","",Replacer.ReplaceText,{current}))

 

However, after running this line there are no changes.

 

I would be grateful if you hint me the solution of this problem.

  • You could just use:

     

    Table.ReplaceValue(#"Previous Table"," ","",Replacer.ReplaceText,Table.ColumnNames(#"Previous Table"))

     

    If you really want to use List.Accumulate, syntax would be:

     

     List.Accumulate(Table.ColumnNames(#"Previous Table"), #"Previous Table", (state, current)=> 
            Table.ReplaceValue(state," ","",Replacer.ReplaceText,{current}))
        

     

1 Reply

  • You could just use:

     

    Table.ReplaceValue(#"Previous Table"," ","",Replacer.ReplaceText,Table.ColumnNames(#"Previous Table"))

     

    If you really want to use List.Accumulate, syntax would be:

     

     List.Accumulate(Table.ColumnNames(#"Previous Table"), #"Previous Table", (state, current)=> 
            Table.ReplaceValue(state," ","",Replacer.ReplaceText,{current}))