Forum Discussion

LEJ's avatar
LEJ
Frequent Visitor
4 years ago
Solved

Filtering columns

Hello.   I have a problem filtering some columns.   First of all. The database is created like this (as a range and not as a table. I can not change it). Days and tasks. People have to enter the ...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi LEJ ,

     

    Add this code in advanced editor.

    "Removed Columns" = 
        let _list = Table.ToList(ColumnName)
        in
        Table.RemoveColumns(#"Changed Type",_list)

    ColumnName should be the table with all column names.

    My Sample:

    Then add the above code to advanced editor of second table.

    Whole code is as below.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTICYmMgNgFiUyA2A2JzpVgdCmRjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t, D = _t, E = _t, F = _t, G = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", Int64.Type}, {"B", Int64.Type}, {"C", Int64.Type}, {"D", Int64.Type}, {"E", Int64.Type}, {"F", Int64.Type}, {"G", Int64.Type}}),
        #"Removed Columns" = 
        let _list = Table.ToList(ColumnName)
        in
        Table.RemoveColumns(#"Changed Type",_list)
    in
        #"Removed Columns"

    Result is as below.

    You can update ColumnName table and Data table and refresh the report to only load the columns you want.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.