none
Use Variable to access Table Column RRS feed

  • Question

  • How do you use a variable to access a column?  This seems trivial but I can't get it to work. The name of the column in "rows" is "Host".

    let
        Source = _Parameters,
        getParam = (param) => 
            let
                rows = Table.SelectRows(Source, each ([IsActive] = true)),
                val = rows[param]{0}
            in
                val,
        host = getParam("Host")
    in
        host

    Expression.Error: The column 'param' of the table wasn't found.

    How do I expand param to be Host?

    Saturday, March 26, 2016 5:20 PM

Answers

  • There we go...

    let
        Source = _Parameters,
        getParam = (param as text) => 
            let
                rows = Table.SelectRows(Source, each ([IsActive] = true)),
                val = Table.Column(rows, param){0}
            in
                val,
        host = getParam("Host")
    in
        host

    • Marked as answer by Mike Hardy Saturday, March 26, 2016 5:47 PM
    Saturday, March 26, 2016 5:47 PM