I have an excel workbook for comparing various tests results. The results are organized in a table within the workbook. For each test run, the test script itself will generate one json file containing the results for the according run, e.g.:
{
"name": "dummy",
"score1": 100,
"scoreX": 99.4,
"TestXY": {
"scoreXYa": 34.5,
"scoreXYb": 45.7
}
}
The excel table which lists all the tests looks like this:
name | score1 | scoreX | TestXY.scoreXYa | TestXY.scoreXYa |
---|---|---|---|---|
dummy1 | 100 | 99.4 | 34.5 | 45.7 |
dummy2 | 120 | 87.0 | 32.5 | 45.3 |
dummy3 | 104 | 98.2 | 36.4 | 45.5 |
I'm looking for a way to statically import the json files and append the results to the list. The lines of the table should not be connected to the according json file as those might be deleted afterwards.
I have created a PowerQuery to load a single json file and transform it into the appropriate format (the format of the table). Now I want to create a static (non-connected) copy and add it to the existing list. The import workflow is:
- User clicks 'Import Result'
- User gets prompted to select one or more json files (via VBA Macro)
- Json file is parsed via PowerQuery
- Static version of the data is appended to the list
This is my PowerQuery script:
let
Source = Json.Document(File.Contents(filename)),
#"Converted to Table" = Record.ToTable(Source),
#"Transposed Table" = Table.Transpose(#"Converted to Table"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"name", type text}, {"score1", Int64.Type}, {"scoreX", type number}, {"TestXY", type any}}),
#"Expanded TestXY" = Table.ExpandRecordColumn(#"Changed Type", "TestXY", {"scoreXYa", "scoreXYb"}, {"TestXY.scoreXYa", "TestXY.scoreXYb"})
in
#"Expanded TestXY"
I am able to to parse the json file. All I need to do now is to append the data to an existing (static) table. Does anybody know how to achieve this? Is this possible via PowerQuery or do I need VBA for this?
Thanks in advance for your help.