Forum Discussion

gvg's avatar
gvg
Post Prodigy
4 years ago
Solved

How to get value from a column with unknown name

Hello folks,

 

Could you help me understand, how do I get value from a column when I do not know its name ? For example


myTable[Column5]     -  returns the value in Column5. 

 

How do I return value from the column if I do not know its name? I only know that it is the 5th column in  myTable?

Thanks!

  • If you are using Table.AddColumn, there is a very simple solution for this.

    Put following in a custom column

    = Record.ToList(_){4}

6 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Most Valuable Professional

    myTable[Column5]  would return a list of values from Column5.

    Equivalent expression would be (Since PQ is 0 indexed, hence 4 is used in place of 5 below)

    Table.Column(myTable,Table.ColumnNames(myTable){4})

    • gvg's avatar
      gvg
      Post Prodigy

      Thanks Vijay_A_Verma , I will experiment with this. I actually need to return not a list, but single value from a corresponding row.

      • Vijay_A_Verma's avatar
        Vijay_A_Verma
        Most Valuable Professional

        The just use the index of that. Hence, if you need 7th row's value then use an index of 6 like below

        Table.Column(myTable,Table.ColumnNames(myTable){4}){6}

  • gvg's avatar
    gvg
    Post Prodigy

    Yep, this is what I was looking for. Thank you !