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
michaelccdf
Helper I
Helper I

Power BI Rest API as a datasource

I have a PBI report which displays information from our nightly data pipelines.  I'd like to show the last refresh date for datasets in the PBI service.  I see the REST api has a resource for this (https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/getrefreshhistory), how can I use the REST api as a data source?

3 REPLIES 3
pranit828
Community Champion
Community Champion

Hi @michaelccdf 

  1. Load the Power BI pbix file associated with your view in Power BI Desktop.

  2. In the External Data section of the ribbon, choose Edit Queries and Open Advanced Editor.

  3. If you have not already modified the query you should see text below with specific table values matching your Analytics view.

     
    let
        Source = VSTS.AnalyticsViews("{OrganizationName}", "{ProjectName}", null),
        #"{tableid}_Table" = Source{[Id="{tableid}",Kind="Table"]}[Data],
    in
        #"{tableid}_Table"

    Modify the query as follows:

    let
        Source = VSTS.AnalyticsViews("account", "project", null),
        #"{tableid}_Table" = Source{[Id="{tableid}",Kind="Table"]}[Data],
        #"Added Refresh Date" = Table.AddColumn(#"{tableid}_Table", "Refresh Date", 
            each DateTimeZone.FixedUtcNow(), type datetimezone)
    in
        #"Added Refresh Date"

     Important

    These examples use UTC. You can adjust the query code based on your specific timezone as described in DateTimeZone function

  4. When finish, choose Done.

  5. Choose Close & Apply to immediately refresh the dataset.

  6. Identify the Refresh Date column under the field.

  7. Add the field to a card to see the last refresh date on your reports.

     

     

 





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Thanks for this, however I'm not clear on what Azure DevOps Analytics views has to do with the PBI REST api.  I'm trying to get the refresh history for my PowerBI datasets into a Power BI report.  One way to do it would be to download the data from the PBI REST API, load it into a database and then have the database as a data source in PBI. 

 

Just wondering if there is a way to use the PBI REST api as a datasource directly, without having to download to a database first.

Hi @michaelccdf ,

 

Please refer to the link.

How to import REST API in Power BI (Load JSON / SOAP XML) 

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.