JensGunther
JensGunther

Reputation: 11

Power Query M - Select Column by Index

I would like to select one Column, may be Column 1, without knowing the name.

How can I get access on (A) the data of this Column and (B) its name?

Thanks a lot in advance for your help

Kind regards Jens

Upvotes: 1

Views: 3552

Answers (1)

Sergey Lossev
Sergey Lossev

Reputation: 1530

Part of table

let
    src1 = #table({"k1", "v1", "z3"}, {{"k11", 11, 10}, {"k12", 12, 20}, {"k13", 13, 30}, {"k14", 14, 40}}),
    cols_all = Table.ColumnNames(src1),
    col_indexed = cols_all{2},
    table_final = Table.SelectColumns(src1, col_indexed)
in
    table_final

List of values

let
    src1 = #table({"k1", "v1", "z3"}, {{"k11", 11, 10}, {"k12", 12, 20}, {"k13", 13, 30}, {"k14", 14, 40}}),
    cols_all = Table.ColumnNames(src1),
    col_indexed = cols_all{2},
    list_final = Table.Column(src1, col_indexed)
in
    list_final

Upvotes: 2

Related Questions