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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
arpost
Advocate V
Advocate V

Need help connecting PBI to public government data

I have a couple of government datasets to which I want to connect Power BI directly:

 

https://data.cms.gov/provider-data/dataset/y9us-9xdf

https://data.cms.gov/provider-data/dataset/dgck-syfz

 

These both offer APIs on the pages above, so I thought I could just connect using PBI's Web connector, but I can't seem to work out how to actually pull the data.

 

arpost_0-1634751511406.png

 

Anyone able to offer some insight?

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

something like this

 

let
    Source = Json.Document(Web.Contents("https://data.cms.gov/provider-data/api/1/metastore/schemas/dataset/items/y9us-9xdf?show_reference_ids=")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Expanded contactPoint" = Table.ExpandRecordColumn(#"Converted to Table", "contactPoint", {"@type", "fn", "hasURL"}, {"contactPoint.@type", "contactPoint.fn", "contactPoint.hasURL"}),
    #"Expanded publisher" = Table.ExpandRecordColumn(#"Expanded contactPoint", "publisher", {"identifier", "data"}, {"publisher.identifier", "publisher.data"}),
    #"Expanded publisher.data" = Table.ExpandRecordColumn(#"Expanded publisher", "publisher.data", {"@type", "name"}, {"publisher.data.@type", "publisher.data.name"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded publisher.data",{{"accessLevel", type text}, {"landingPage", type text}, {"bureauCode", type any}, {"issued", type date}, {"@type", type text}, {"modified", type date}, {"released", type date}, {"keyword", type any}, {"contactPoint.@type", type text}, {"contactPoint.fn", type text}, {"contactPoint.hasURL", type text}, {"publisher.identifier", type text}, {"publisher.data.@type", type text}, {"publisher.data.name", type text}, {"identifier", type text}, {"description", type text}, {"title", type text}, {"programCode", type any}, {"distribution", type any}, {"theme", type any}, {"%modified", type date}})
in
    #"Changed Type"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @arpost,

Did lbendlin 's suggestions help with your scenario? if that is the case, you can consider Kudo or accept his suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information about your requirements to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
lbendlin
Super User
Super User

something like this

 

let
    Source = Json.Document(Web.Contents("https://data.cms.gov/provider-data/api/1/metastore/schemas/dataset/items/y9us-9xdf?show_reference_ids=")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Expanded contactPoint" = Table.ExpandRecordColumn(#"Converted to Table", "contactPoint", {"@type", "fn", "hasURL"}, {"contactPoint.@type", "contactPoint.fn", "contactPoint.hasURL"}),
    #"Expanded publisher" = Table.ExpandRecordColumn(#"Expanded contactPoint", "publisher", {"identifier", "data"}, {"publisher.identifier", "publisher.data"}),
    #"Expanded publisher.data" = Table.ExpandRecordColumn(#"Expanded publisher", "publisher.data", {"@type", "name"}, {"publisher.data.@type", "publisher.data.name"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded publisher.data",{{"accessLevel", type text}, {"landingPage", type text}, {"bureauCode", type any}, {"issued", type date}, {"@type", type text}, {"modified", type date}, {"released", type date}, {"keyword", type any}, {"contactPoint.@type", type text}, {"contactPoint.fn", type text}, {"contactPoint.hasURL", type text}, {"publisher.identifier", type text}, {"publisher.data.@type", type text}, {"publisher.data.name", type text}, {"identifier", type text}, {"description", type text}, {"title", type text}, {"programCode", type any}, {"distribution", type any}, {"theme", type any}, {"%modified", type date}})
in
    #"Changed Type"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.