Wednesday, January 31, 2018

How to retrieve OData v4 fast in Power BI

I recently blogged about how Power BI has a bug which ignores the select statements when querying an OData v4 endpoint. Even though the columns would include any data, it still bugged me so much that I wanted to find a way around it.

Turns out that’s much easier than you would expect.

I recently explored some of the different data loading capabilities in PBI, and it turns out that there’s a Json.Document function which allows you to handle OData at an even lower level.

So what I did was take my original uri and query string: https://<org>$select=name

Then I put it into a Json.Document(Web.Contents())

And voila, this is the result


Navigating into that list, you can then right click the column and select “To Table”. This will present you with a table of records ready to be exploded:


So, time to do a little speed testing

Using: = OData.Feed("https://<org>$select=name")


Using: = Json.Document(Web.Contents("https://<org>$select=name"))


Enough said?


  1. Unfortunately max 5000 records only

  2. How did you put it into the JSON.Document...what were your steps for a newbie?

    1. First you have to generate an OData query. If you haven't spent extensive time building queries before I recommend looking into the OData query builder created by Jason Latimer

      After you have a valid OData url then you can create a new blank query in Power BI. Then, click on the advanced editor, and add the following:
      Source = Json.Document(Web.Contents("your-url-inside-here-do-not-remove-quotation-marks")

      Finally, drill into the list and expand the way you want to use the data. See my other blog post for how to expand Dynamics data from a Json.Document here:

  3. Tried this out and seems to be quick, but does not seem to work for lookup fields. Lookups error out and you cannot access even the associated guid...or maybe I'm doing it wrong...

    1. Not sure what you're doing, but I do get lookup ids when I use this. Joins and expands needs to be done manually since Web.Contents doesn't utilize the ODatav4 capabilities.