Forum Discussion
Loading firebase database to Power BI
- 9 years ago
Another approach is to use the function Record.ToTable(json) to drill down the json path. Please follow the query example below
let
json = Json.Document(File.Contents("C:\Users\cotrutai\Downloads\test.json")),
level0 = Record.ToTable(json),
level1 = Table.AddColumn(level0, "level1", each Record.ToTable([Value])),
level1_exp = Table.ExpandTableColumn(level1, "level1", {"Name", "Value"}, {"level1.Name", "level1.Value"}),
level2 = Table.AddColumn(level1_exp, "level2", each Record.ToTable([level1.Value])),
level2_exp = Table.ExpandTableColumn(level2, "level2", {"Name", "Value"}, {"level2.Name", "level2.Value"}),
out = Table.ExpandRecordColumn(level2_exp, "level2.Value", {"date", "eatmyvegetables", "postponeuntildeadline", "r", "score", "telltruthtospouse"}, {"date", "eatmyvegetables", "postponeuntildeadline", "r", "score", "telltruthtospouse"})
in
out
Here is a raw cut of what you can do. if json is the object containing the json you've listed in your question then you can get to the raw data via the following query:
= Table.FromRecords(
List.Accumulate(List.Accumulate(Record.FieldValues(json)
,{}
, (s,c)=>s&Record.FieldValues(c)
)
,{}
,(si,ci)=>si&Record.FieldValues(ci)
)
)
Hi hugoberry, this really helped me. Unfortunately I also got my hands on some JSON a bit more advanced. I tried to follow your example, but wasn't able to extract. I have made a new Thread, so hopefully others can learn from it too. I would greatly appreciate it, if you would take a look at it: http://community.powerbi.com/t5/Desktop/A-bit-more-advanced-JSON-to-Power-BI/m-p/130000#U130000
br, Simon