Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

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.

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

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}))
    

 

View solution in original post

1 REPLY 1
ronrsnfld
Super User
Super User

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}))
    

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors