由数值、布尔值以及字母组成的列表
{123, true, "A"}
由数值组成的列表
{1, 2, 3}
大列表内嵌套两个数值组成的小列表
{
{1, 2, 3},
{4, 5, 6}
}
列表内嵌套两个记录
{
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
}
从列表内取序号为0的数值,结果为123
{123, true, "A"}{0}
先从大列表内取序号为0的第一个子列表,再从子列表中取序号为1的值,结果为2
{
{1, 2, 3},
{4, 5, 6}
}{0}{1}
不加""的表达形式、例如OrderID
加#和""的表达形式、例如#"Today's data is:"
例1:定义字段以及显示记录内所有内容
let Source =
[
OrderID = 1,
#"CustomerID" = 1,
Item = "Fishing rod",
Price = 100.00
]
in Source
例2:定义字段以及显示记录内[Item]字段的值
let Source =
[
OrderID = 1,
#"CustomerID" = 1,
= "Fishing rod",
Price = 100.00
]
in Source[#"CustomerID"] //equals 1
例1:隐式字段表
let
Source = #table(
{"OrderID", "CustomerID", "Item", "Price"},
{
{1, 1, "Fishing rod", 100.00},
{2, 1, "1 lb. worms", 5.00}
}
)
in Source
根据每列第一个值确定该列的数据类型
例2:显示字段表
let
Source = #table(
type table [OrderID = number,
CustomerID = number,
Item = text,
Price = number],
{
{1, 1, "Fishing rod", 100.00},
{2, 1, "1 lb. worms", 5.00}
} )
in Source
无论有多少条记录,哪怕只有一条也要用双层话括号括起来
例3:建表后取表中第一行数据
let Source =
#table( type table
[OrderID = number,
CustomerID = number,
Item = text,
Price = number],
{
{1, 1, "Fishing rod", 100.00},
{2, 1, "1 lb. worms", 5.00}
} )
in Source{1}
数据结构中可以包含任意M值 例1:复合数据结构的列表
let Source =
{
1, //数值
"Bob", //文本
DateTime.ToText(DateTime.LocalNow(), "yyyy-MMdd"), //函数值
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0] //记录
}
in Source
例2:包含子列表的记录
let Source =
[
CustomerID = 1,
Name = "Bob",
Phone = "1234567",
Orders = {
[OrderID = 1,CustomerID = 1,Item = "Fishing rod", Price = 100.0],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0]
}
]
in Source
[ A1 = A2 * 2,
A2 = A3 + 1,
A3 = 1 ]
例2:复合嵌套记录内元素间的引用计算
[
Sales =
{
[ Year = 2007, FirstHalf = 1000, SecondHalf = 1100, Total = FirstHalf + SecondHalf ],
[ Year = 2008, FirstHalf = 1200, SecondHalf = 1300, Total = FirstHalf + SecondHalf ]
},
#"Total Sales" = Sales{0}[Total] + Sales{1}[Total]
]
(teamname as text)=>
let
源 = Web.Page(Web.Contents("https://china.nba.com/teams/stats/#!/"& teamname )),
球队信息 = 源{0}[Data]
in
源