none
How using the #table() function RRS feed

  • Question

  • Hi,

    I'd like to understand how using the #table() function by a sample (without connecting to an external data source).

    Any helps to me, please?

    Thanks

    Friday, February 3, 2017 3:00 PM

Answers

  • The result from #table is a table as any other table, so you can do anything with the results from #table you can do with any other table.

    Just some random examples:

    let
        Source = #table(type table[Value = number, Category = text],
                    {{1, "B"},
                     {2, "C"}}),
        #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
        #"Sorted Rows" = Table.Sort(#"Added Index",{{"Index", Order.Descending}}),
        #"Inserted Multiplication" = Table.AddColumn(#"Sorted Rows", "Inserted Multiplication", each [Value] * 10, type number)
    in
        #"Inserted Multiplication"


    • Edited by MarcelBeug Tuesday, February 7, 2017 10:50 AM
    • Marked as answer by pscorca Wednesday, February 8, 2017 8:05 AM
    Tuesday, February 7, 2017 10:50 AM

All replies

  • Chris Webb's blog post gives some examples.

    Regards

    Laurence

    Friday, February 3, 2017 3:12 PM
  • Please see section 4.13 of the Formula Language Specification, which you can download here:

    https://msdn.microsoft.com/en-us/library/mt211003.aspx?f=255&MSPPError=-2147217396

    I use #table when I want to create a static lookup table - one not dependent on any external source.

    Friday, February 3, 2017 3:18 PM
  • Hi, thanks for your reply, but I don't see how using this statement with other statements in a same query.

    Tuesday, February 7, 2017 9:29 AM
  • The result from #table is a table as any other table, so you can do anything with the results from #table you can do with any other table.

    Just some random examples:

    let
        Source = #table(type table[Value = number, Category = text],
                    {{1, "B"},
                     {2, "C"}}),
        #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
        #"Sorted Rows" = Table.Sort(#"Added Index",{{"Index", Order.Descending}}),
        #"Inserted Multiplication" = Table.AddColumn(#"Sorted Rows", "Inserted Multiplication", each [Value] * 10, type number)
    in
        #"Inserted Multiplication"


    • Edited by MarcelBeug Tuesday, February 7, 2017 10:50 AM
    • Marked as answer by pscorca Wednesday, February 8, 2017 8:05 AM
    Tuesday, February 7, 2017 10:50 AM