2
votes

What are the differences between an item of type #table and a list of type #record in powerQuery? For example:

data = {
    [id=1, name="tom"],
    [id=2, name="sarah]
}

And:

data = #table(
    {"id", "name"},
    {
      {1, "tom"},
      {2, "sarah"}
    },
)

Are they two ways to write the same thing, or should one be used over the other in certain cases?

1
These series have good explanations on the topicsRicardo Diaz

1 Answers

1
votes

The main difference is table may require strict data types, and only includes records, while list of records can also include values of other types, such as numbers or characters.

Your example can have column types defined in advance:

data = #table(
    type table [id=Int64.Type, name=Text.Type],
    {
      {1, "tom"},
      {2, "sarah"}
    },
)

As opposite to a list:

data = {
    [id=1, name="tom"],
    [id=2, name="sarah"],
    1,
    "a"
}