Forum Discussion

PBI_newuser's avatar
PBI_newuser
Post Prodigy
1 year ago
Solved

Last Refreshed Date for DirectQuery Datasets in Power BI

I have a report that pulls data from multiple Power BI datasets using DirectQuery. How can I create a measure or retrieve the last refreshed date for each dataset in the report?  
  • danextian's avatar
    1 year ago

    Hi PBI_newuser 

     

    Are you connecting to semantic models via direct query or connecting to databases via direct query? if the former, you will need to add a table that contains a column on when approximate the refresh happened. In DAX:

    RefreshTable =
    ROW ( "Refresh", UTCNOW () + DIVIDE ( 8, 24 ) )
    

    Replace 8 with your UTC offset to create a single-row table that reflects your local time after all tables have been imported. Keep in mind that the Power BI service operates in UTC.

     

    For direct query connections to databases, there is no reliable way to achieve this. You can use UTCNOW() + DIVIDE(8, 24) in a measure, but the value will change dynamically as users interact with the visuals. Since the result is cached, navigating back to a previous report state will revert to the earlier time.

     

    If "datasets" refers to individual tables in a semantic model, it is not possible to achieve this. In direct query mode, data updates based on user interactions, so the closest approximation remains UTCNOW() + DIVIDE(8, 24).