将json二维数组转换为表
我很难找到如何将2D数组(通过JSON格式转换)转换成表 我的JSON:将json二维数组转换为表,json,powerquery,Json,Powerquery,我很难找到如何将2D数组(通过JSON格式转换)转换成表 我的JSON: [ ["index", 1, 2, 3, 4, 5, 6, 7, 8, 9], ["type", "years", "years", "years", "quarters", "quarters", "quarters", "months", "months", "months"], ["period", "2016", "2017", "2018", "Q2", "Q3", "Q4", "Dec", "Jan
[
["index", 1, 2, 3, 4, 5, 6, 7, 8, 9],
["type", "years", "years", "years", "quarters", "quarters", "quarters", "months", "months", "months"],
["period", "2016", "2017", "2018", "Q2", "Q3", "Q4", "Dec", "Jan", "Feb"],
["nb_month", 12, 12, 12, 3, 3, 3, 1, 1, 1],
["MY_scrap", 0, 54, 1529, 325, 445, 532, 120, 193, 131],
["MY_completed", 6, 89, 2895, 394, 722, 1622, 437, 805, 542],
["SV_total", 6, 1806, 36520, 6143, 11772, 15318, 3579, 6407, 5216],
["SV_scrap", 0, 54, 1529, 325, 445, 532, 120, 193, 131],
["SV_other", 6, 1752, 34809, 5808, 11198, 14773, 3449, 6214, 5081],
["WIP", 0, 971, 3214, 1493, 2395, 3214, 3214, 3832, 4445],
["WLS", 0, 178, 650, 390, 475, 650, 650, 709, 902]
]
JSON上的每一行都是表中的一列,JSON中的第一行是表头
我开始玩power query,最后得到了代码的开头:
let
Source = Json.Document(Web.Contents("http://localhost/api/test")),
trans1 = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Transposed Table" = Table.Transpose(trans1)
in
#"Transposed Table"
结果如下:
但从这里我不明白如何管理一个适当的列表扩展
谢谢你的帮助 我相信有一个M函数对你非常有用。Table.FromColumns(以列表形式列出) 我想这正是你想要的
谢谢,这正是我需要的!!:)
let
Source = Json.Document(Web.Contents("http://localhost/api/test")),
TableResult = Table.FromColumns(Source),
#"Promoted Headers" = Table.PromoteHeaders(TableResult, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"index", Int64.Type}, {"type", type text}, {"period", type text}, {"nb_month", Int64.Type}, {"MY_scrap", Int64.Type}, {"MY_completed", Int64.Type}, {"SV_total", Int64.Type}, {"SV_scrap", Int64.Type}, {"SV_other", Int64.Type}, {"WIP", Int64.Type}, {"WLS", Int64.Type}})
in
#"Changed Type"