Thursday, December 6, 2018

How do you load JSON data into PowerBI?

JSON data source were recently added to Power BI Data sources.

{
I have taken this JSON file from the following site;

 https://www.kodingmadesimple.com

and I will be using in this post.

Here is an abbreviated JSON file (with *.json extension) I am using.
--------------------------------------

  "data": [
    {
      "name": "Garrett Winters",
      "designation": "Accountant",
      "salary": "$170,750",
      "joining_date": "2011/07/25",
      "office": "Tokyo",
      "extension": "8422"
    },
    {
      "name": "Brielle Williamson",
      "designation": "Integration Specialist",
      "salary": "$372,000",
      "joining_date": "2012/12/02",
      "office": "New York",
      "extension": "4804"
    },
     ,
     ,
    {
      "name": "Quinn Flynn",
      "designation": "Support Lead",
      "salary": "$342,000",
      "joining_date": "2013/03/03",
      "office": "Edinburgh",
      "extension": "9497"
    }
  ]
}

-----------
Note that each Json element has six attributes.

Step 1:
You first need to save it to a location of your choice. You could also have it on an URL, but here it is assumed to be in one of the folders.

Launch PowerBI; Click GetData; Click More...

Click JSON


You need to browse and locate your JSON file (it will have  a.json extension).



My Koding.json file is now in Data View as shown.


 I go back to Edit Queries as I did not edit earlier.


 Now I have a query as shown in the left pane.


I had 15 elements in the JSOn file and they have become 16 records after getting it into PowerBI. Now go back to query using Edit Query as before. Now you see an extra control in Column 1 for splitting into its components.



I click the split control. The Query now appears as shown.


Now I convert this into table as shown above. Now what I see in DataView is the following:


The six elements are resolved into six fields as shown above. We will use this later. Click File | Save to save this file in the .pbix format. Presently it has the JSON data only.


That is all folks!

No comments: