Forum Discussion

Newbie22's avatar
Newbie22
Resolver I
3 years ago
Solved

Replace Value of multiple columns using Query Editor but the columns are increasing every refresh.

Hi All,   I have a growing file as data source. Columns are increasing every refresh in Power BI. I need to replace all columns with "null" to 0 and it should also replace those "additional" colum...
  • ams1's avatar
    ams1
    3 years ago

    Hi,

     

    The code in your Advanced Editor should look something like below.

     

    let
    Source = Excel.Workbook(File.Contents("C:\Users\xxxx\Downloads\sampledata.xlsx"), null, true),
    #"Removed Other Columns1" = Table.SelectColumns(Source,{"Data"}),
    Data = #"Removed Other Columns1"{0}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Data, [PromoteAllScalars=true]),
    // **********
    ReplaceNulls = Table.TransformColumns(#"Promoted Headers",{},(x) => Replacer.ReplaceValue(x,null,0))
    // **********
    in
    ReplaceNulls // don't forget about this also 🙂