Forum Discussion

kb177's avatar
kb177
Icon for Helper II rankHelper II
2 years ago
Solved

replace values for all existing and new columns

Is there any way to replace values for all columns i.e existing and new columns dynamically instead of hard coding the column names

 

as example if today the source data has 4 columns and the next day if there are 5 columns how to replace values in the col4 values as well as the replace query step wont have col4 in the code.

ID  col1 col2 col3

 

ID col1 col2 col3 col4

  • Hi,

    Since you have not shared any specific details, here is a generic answer.  These 2 lines of M code will replace null with 0 in all columns (including additional columns after refreshing)

    GetColumnNames = Table.ColumnNames(#"Promoted Headers"),
    #"Replaced Value01" = Table.ReplaceValue(#"Promoted Headers",null,0,Replacer.ReplaceValue,GetColumnNames)

    Hope this helps.

2 Replies