在PowerBI中将json列表记录转换为表值
我对Power BI完全是新手,所以我尝试了不同的方法将JSON文件转换为表,但到目前为止还没有成功在PowerBI中将json列表记录转换为表值,json,powerbi,powerbi-desktop,Json,Powerbi,Powerbi Desktop,我对Power BI完全是新手,所以我尝试了不同的方法将JSON文件转换为表,但到目前为止还没有成功 { "Family": [ { "Father": "F1", "Age": 50, "Mother": "M1", "MAge": 49, "Children": [ { "Nam
{
"Family": [
{
"Father": "F1",
"Age": 50,
"Mother": "M1",
"MAge": 49,
"Children": [
{
"Name": "C1"
},
{
"Name": "C2"
}
]
},
{
"Father": "F2",
"Age": 55,
"Mother": "M2",
"MAge": 53,
"Children": [
{
"Name": "Cc1"
},
{
"Name": "Cc2"
}
]
}
]
}
我正试图将其转换为下表
Father Age Mother MAge
F1 50 M1 49
F2 55 M2 53
我试着像转换表和转置这是不工作的,我总是得到这样的错误
表达式.错误:无法将类型为Record的值转换为类型
我缺少
ExpandRecordColumn
函数的步骤。在我把它放进我的查询之后。成功了
let
Source = Json.Document(File.Contents("C:\Users\hp\Desktop\File.JSON")),
Family = Source[Family],
#"Converted to Table" = Table.FromList(Family, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Father", "Age", "Mother", "MAge", "Children"}, {"Father", "Age", "Mother", "MAge", "Children"})
in
#"Expanded Column1"
让我为那些不想使用Power BI用户界面(桌面/Web)编写Power Query和jsut的人分享一个分步指南
let
Source = Json.Document(File.Contents("C:\Users\rag\Desktop\data.json")),
Family = Source[Family],
#"Converted to Table" = Table.FromList(Family, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Father", "Age", "Mother", "MAge"}, {"Father", "Age", "Mother", "MAge"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Column1",{{"Age", type number}, {"MAge", type number}})
in
#"Changed Type"
更多信息: