Import Multiple json File in Power Query

When using Power BI often you want to be able to aggregate more information or more data sources in a single query .

Take for example the json file , but this procedure is also valid for other data formats , it often happens that the information is spread across multiple files , and no single document , or is spread over several sites .

What can traditionally do is create a number of queries ( one for each file ) and then merge them together later . Or we can use a simple string of code that allows us to unify them all into a single query that automatically calls the various pages and aggregates .

Let’s start from the beginning .

1. Create a query

The first thing to do is prepare our basic query to the json file. We take any file in json and prepare them as we need to import it into the model . Having done this we go into the rich editor of the query just built and we go to retrieve the script that we have defined , we will show you one example:

Origine = Json.Document(Web.Contents(“http:\\file.1231321.json”)),
#”Conversione in tabella” = Record.ToTable(Origine),
#”Tabella Value espansa” = Table.ExpandListColumn(#”Conversione in tabella”, “Value”),
#”Tabella Value espansa1″ = Table.ExpandRecordColumn(#”Tabella Value espansa”, “Value”, {“id”, “team”, “events”}, {“”, “”, “”}),
#”Tabella espansa” = Table.ExpandListColumn(#”Tabella Value espansa1″, “”),
#”Tabella espansa1″ = Table.ExpandRecordColumn(#”Tabella espansa”, “”, {“id”, “type”, “x”, “y”, “player”, “endingArea”, “time”}, {“”, “”, “”, “”, “”, “”, “”}),
#”Tabella espansa” = Table.ExpandRecordColumn(#”Tabella espansa1″, “”, {“x”, “y”, “z”}, {“”, “”, “”}),
#”Aggiunta colonna personalizzata” = Table.AddColumn(#”Tabella espansa”, “Custom”, each if([] – 1442342722)/60 > 45 then (([Value.time] – 1442342722)/60) -15 else ([] – 1442342722)/60),
#”Modificato tipo” = Table.TransformColumnTypes(#”Aggiunta colonna personalizzata”,{{“Custom”, type number}}),
#”Rinominate colonne” = Table.RenameColumns(#”Modificato tipo”,{{“Custom”, “Timing”}})
#”Rinominate colonne”

Copy the query just made in notepad so always in the advanced editor delete the entire query and replace with the following string:

Let loadjson =Contents) =>

in loadJSON

This little script transforms our queries power query in a function that can be called from other power query query . But before we close the query power of queries you must be entered within the previous script loadjson everything we saved in notepad , so let’s make a small change.

let’s replace the segunete string of code :

    Origine = Json.Document(Web.Contents(“http:\\file.1231321.json”)),

with this:

    Origine = Json.Document(Web.Contents(contents)),

With this change we’re going to say to power queries that the json file will be contained in the variable contents will be contained the address of the json file. The end result should be the following :


At this point we give a name to our query and save . If everything works properly it should have converted to fuction and if we recall and enter an address you should get the query .

Now back to excel excel and we prepare a multiplication table with a list of all the addresses where are our json file and convert it in the table:



we select the table and from powerquery tab select from table:


We create e new column with this formual:


Attention is very important to write the function properly , also count uppercase and lowercase . At this point if you have successfully written the function will get a new column with written inside table for each row :


If we expand the column get the query written previously aggregating But for all the files that we included . If we want to change or add a json file, we simply add to the multiplication table a new line and you’re done .


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di

Stai commentando usando il tuo account Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...