Forum Discussion
gwhiteman
1 year agoFrequent Visitor
Importing multiple JSON files int PBI (Data Source = Admin API GetDatasourcesAsAdmin)
I am using the Admin Power BI API “GetDatasourcesAsAdmin” to extract connection details for semantic models we manage. I have a list of models (by datasetId) which I loop through and export the infor...
- 1 year ago
Here is a way to check for record vs. list as part of your parsing. As stated previously, you can simply wrap the records you find into a list and then treat all outputs the same.
let Source = Folder.Files("<local file location with your json examples saved>"), //parse the json, if a single record, wrap in list so they are all list of records ParseJson = List.Transform( Source[Content] , //binaries are in "Content" column each let json = Json.Document( _ ), valTypeIsRecord = Type.Is( Value.Type( json ), type record ) in if valTypeIsRecord //if it's a record then { json } //wrap in a list else json //otherwise leave as is ), //list of list of records --> list of records CombineRecords = List.Combine( ParseJson ), //uniform transformation - Table.FromRecords is designed for list of records ToTable = Table.FromRecords( CombineRecords, //provide exact types here so we don't have to later type table [ datasourceType=text, connectionDetails=[server=text,database=text], datasourceId=text, gatewayId=text ] ), ExpandConnectionDetails = Table.ExpandRecordColumn( ToTable, "connectionDetails", {"server", "database"}, {"connectionDetails.server", "connectionDetails.database"} ) in ExpandConnectionDetailsPics of steps so you can see better what's going on:
v-prasare
1 year agoCommunity Support
gwhiteman, As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by our community members for your issue worked? or let us know if you need any further assistance here?
Thanks,
Prashanth Are
MS Fabric community support
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query