Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
Anonymous
Not applicable

Pass Postcodes to ofcom API

Hi All,

 

Fairly new to PowerBI so bear with me.

 

Ihave a list of Postcodes i want to pass to the ofcom api to check thier broadband speed. I created a function as below

 

let
get_speed = (#"site Postcodes" as text) =>

let
Source = Json.Document(Web.Contents("https://api-proxy.ofcom.org.uk/broadband/coverage/"&#"site Postcodes"&"", [Headers=[#"Ocp-Apim-Subscription-Key"="5xxxxxxxxx", Name="api-proxy.ofcom.org.uk"]])),
Availability = Source[Availability]
in
Availability
in

get_speed

 

I then try to create a custom column to iterate the function on each postcode 

 

=FN_NetworkSpeed[Postcode]

 

Im being thrown the error

 

: We cannot apply field access to the type Function.
Details:
Value=[Function]
Key=Post Code

 

Im not sure how to fix it, can anyone help 

 

 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

HI @Anonymous 

Download this PBIX file with code - just enter your API key.

I signed up for an OfCom API key to test this.  This code is tested and working.  The Post Code has to be in upper case and without spaces e.g. E146NJ

(PostCode as text) =>

    let
        Source = Json.Document(
            
                    Web.Contents(
            
                        "https://api-proxy.ofcom.org.uk/broadband/coverage/"&Text.Replace(Text.Upper(PostCode), " ", ""), 
                    
                        [Headers=[#"Ocp-Apim-Subscription-Key"="xxxxxx", Name="api-proxy.ofcom.org.uk"]])),

        Availability = Source[Availability]
    in
        Availability

If you start with a column of post codes, the API will return a list of records for each house in that post code

postcodes.png

 

You can expand these lists to get the records and then expand those records

house-speed.png

 

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

3 REPLIES 3
PhilipTreacy
Super User
Super User

HI @Anonymous 

Download this PBIX file with code - just enter your API key.

I signed up for an OfCom API key to test this.  This code is tested and working.  The Post Code has to be in upper case and without spaces e.g. E146NJ

(PostCode as text) =>

    let
        Source = Json.Document(
            
                    Web.Contents(
            
                        "https://api-proxy.ofcom.org.uk/broadband/coverage/"&Text.Replace(Text.Upper(PostCode), " ", ""), 
                    
                        [Headers=[#"Ocp-Apim-Subscription-Key"="xxxxxx", Name="api-proxy.ofcom.org.uk"]])),

        Availability = Source[Availability]
    in
        Availability

If you start with a column of post codes, the API will return a list of records for each house in that post code

postcodes.png

 

You can expand these lists to get the records and then expand those records

house-speed.png

 

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


mahoneypat
Microsoft Employee
Microsoft Employee

Please try this intead for your function.  Your previous expression is a query that includes a function, not just a function that can be invoked in another query.

 

(#"site Postcodes" as text) =>
let
Source = Json.Document(
Web.Contents(
"https://api-proxy.ofcom.org.uk/broadband/coverage/" & #"site Postcodes" & "",
[Headers = [#"Ocp-Apim-Subscription-Key" = "5xxxxxxxxx", Name = "api-proxy.ofcom.org.uk"]]
)
),
Availability = Source[Availability]
in
Availability





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


amitchandak
Super User
Super User

@Anonymous , refer if this can help a bit

https://blog.crossjoin.co.uk/2016/08/16/using-the-relativepath-and-query-options-with-web-contents-in-power-query-and-power-bi-m-code/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.