Forum Discussion

AlexGT92's avatar
AlexGT92
Regular Visitor
3 years ago

Select Columns in a nested Table, based on a list of column name

Hello 

I am trying to select few columns in a nested Table. I have defined the columns name to be selected in a list in a previous step.

I tried Select.Columns and List.Contains but because the data is in a nested column the formulas dont work.

 

here is the code I have at the moment

=Table.AddColumn(PreviousStep, "SelectColumn", each List.Contains(ListColumn,[NestedTableColumn])=true)

 

Could you please help me on this ?

6 Replies

  • your code is missing a few bits and pieces.  What exactly are you planning to put into "SelectColumn" ?  a single column value, or a collection of columns?

    • AlexGT92's avatar
      AlexGT92
      Regular Visitor

      Hi, Select Column is the new table name where I have some of the columns from the previous step. I would like to select few of the columns from the previous table. And this selection should be based on a list (with column names).

      • lbendlin's avatar
        lbendlin
        Super User

        Please provide sanitized sample data that fully covers your issue.
        Please show the expected outcome based on the sample data you provided.

  • Galvafan's avatar
    Galvafan
    Frequent Visitor

    hi guys sb found a solution? I have similar problem. I tried below but not working.

    = Table.TransformColumns(previous_step, {"Skip", each _fx_SelecionaColunas([Skip], [ColNames])})

    ((((_fx_SelecionaColunas))) =
    (tbl as table, col_with_list as list) =>
    let  selected_columns = Table.SelectColumns(tbl, col_with_list)  in selected_columns 

  • Galvafan's avatar
    Galvafan
    Frequent Visitor

    hi guys sb found a solution? I have similar problem. I tried below but not working.

    = Table.TransformColumns(previous_step, {"Skip", each _fx_SelecionaColunas([Skip], [ColNames])})

    ((((_fx_SelecionaColunas))) =
    (tbl as table, col_with_list as list) =>
    let  selected_columns = Table.SelectColumns(tbl, col_with_list)  in selected_columns