What is the difference between [column] and Table.Column(Table, “column”) in M/PowerBI/PowerQuery

前端 未结 1 1449
予麋鹿
予麋鹿 2021-01-27 00:21

Ciao there!

I have a problem with a difference between [column] and Table.Column(Table, \"column\") in M/PowerBI/PowerQuery.


Example Table:
\'#____colu

相关标签:
1条回答
  • 2021-01-27 01:02

    Table.Column returns a list from taking one table column.

    [column] returns the value in that column for the current row.

    In this case, I find Table.TransformColumns more flexible than Table.ReplaceValue.

    If you used the GUI to transform several columns to UPPERCASE it would generate code that looks like this:

    = Table.TransformColumns(
        PrevQueryTable,
        {{"Col1", Text.Upper, type text},
         {"Col2", Text.Upper, type text},
         {"Col3", Text.Upper, type text}})
    

    This can serve as a template for how we want to write our own transformation. Suppose we have a list of column names ColumnList (from Table.ColumnNames for example). We could transform that list by adding the transformation functions to each element like so:

    = Table.TransformColumns(
        PrevQueryTable,
        List.Transform(
            ColumnList,
            each {_, each "TEST", type text}
        )
      )
    

    E.g. "col1" gets transformed into {"col1", each "TEST", type text}

    0 讨论(0)
提交回复
热议问题