Forum Discussion

Andreas_H's avatar
Andreas_H
Frequent Visitor
8 years ago
Solved

Power BI Desktop Query, replace multiple strings in a single command line via 'Table.ReplaceValue'

Good Evening Power BI community,   after a litlle pause I am now back into Power BI Desktop and I am making good progress given the fact that I am sill to be determined as beginner...   I figured...
  • ImkeF's avatar
    8 years ago

    Hi Andreas,

    this will not work unfortunately.

     

    The function-definition will show you why:

     

    Table.RenameColumns(table as table, renames as list, optional missingField as nullable number) as table 

     

    in this function the rename-arguments are expected as list & this is normally a sign that multipe values are accepted. You can also indicate this at the syntax of your actual formula:

     

    = Table.RenameColumns(#"Spalte nach Trennzeichen teilen", { {"Act @B17", "PA Act @B17"}, {"Bud (p) @B17", "FY Bud (p) @B17" } } )

     

    You have your renamings in curly brackets and then there is another curly bracket around them all: This makes them a list. So you can add as many into the list as needed.

     

    But Table.ReplaceValue(table as table, oldValue as any, newValue as any,replacer as function, columnsToSearch as {Text}) 

    is missing the list-element

     

    and the syntax is missing the curly brackets:

    Table.ReplaceValue(#"GeƤnderter Typ","Innovation Budget","IB",Replacer.ReplaceValue,{"Portfolio Category"})

     

    So no chance with this command unfortunately.

     

    BTW: I've set up a user group in Berlin: https://www.pbiusergroup.com/communities/community-home?CommunityKey=55090a51-8ae4-4165-abd6-29f1bb1ae322 and we try to have our first meeting end of September (still organizing a meeting location). Would be great to see you there!

    Cheers - Imke