如何根据 JSON 的 Power Query 中的值指定数组元素
How to specify array element based on a value in Power Query for JSON
我有一个 JSON 嵌套数组源。每个对象都有一个“键”元素。我想要 select Key="canada" 的元素。我将如何指定它?
什么有效:
let
Source = Json.Document(Web.Contents("https://kustom.radio-canada.ca/covid-19")),
Source1 = Source{22},
但它被硬编码为第 22 个值。
什么不起作用:
Source1 = Source{[Key="canada"]}
这个returns:
Expression.Error: We cannot convert a value of type Record to type Number.
Details:
Value=
Key=canada
Type=[Type]
那么,我该如何指定呢?
试试这个
let
Source = Json.Document(Web.Contents("https://kustom.radio-canada.ca/covid-19")),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Key", "Api", "Name", "NameFr", "Country", "CountryFr", "State", "StateFr", "Lat", "Long", "Confirmed", "Deaths", "Recovered", "Population", "History", "Regions", "DateUpdate"}, {"Key", "Api", "Name", "NameFr", "Country", "CountryFr", "State", "StateFr", "Lat", "Long", "Confirmed", "Deaths", "Recovered", "Population", "History", "Regions", "DateUpdate"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Column1", each ([Key] = "canada"))
in
#"Filtered Rows"
我有一个 JSON 嵌套数组源。每个对象都有一个“键”元素。我想要 select Key="canada" 的元素。我将如何指定它?
什么有效:
let
Source = Json.Document(Web.Contents("https://kustom.radio-canada.ca/covid-19")),
Source1 = Source{22},
但它被硬编码为第 22 个值。
什么不起作用:
Source1 = Source{[Key="canada"]}
这个returns:
Expression.Error: We cannot convert a value of type Record to type Number. Details: Value= Key=canada Type=[Type]
那么,我该如何指定呢?
试试这个
let
Source = Json.Document(Web.Contents("https://kustom.radio-canada.ca/covid-19")),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Key", "Api", "Name", "NameFr", "Country", "CountryFr", "State", "StateFr", "Lat", "Long", "Confirmed", "Deaths", "Recovered", "Population", "History", "Regions", "DateUpdate"}, {"Key", "Api", "Name", "NameFr", "Country", "CountryFr", "State", "StateFr", "Lat", "Long", "Confirmed", "Deaths", "Recovered", "Population", "History", "Regions", "DateUpdate"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Column1", each ([Key] = "canada"))
in
#"Filtered Rows"