title | titleSuffix | description | ms.subservice | ms.custom | ms.author | author | ms.topic | ai-usage | monikerRange | ms.date |
---|---|---|---|---|---|---|---|---|---|---|
Add last refresh date to a Power BI report |
Azure DevOps |
Learn how to add a field showing the last refresh date to an existing Power BI report based on Analytics. |
azure-devops-analytics |
engagement-fy23 |
chcomley |
chcomley |
how-to |
ai-assisted |
>= azure-devops-2019 |
10/08/2024 |
[!INCLUDE version-gt-eq-2019]
Adding a last refresh date to a report helps users understand how current the data is. You can display the date and time of the last data update using a card in the report. Regularly refreshing the data models in Power BI ensures that all information is up-to-date.
The steps to add a last refresh date vary based on the source of your Power BI report, whether it's an Analytics view, Power BI, or an OData query.
Note
Several Analytics entity types, such as WorkItemRevision
, WorkItem
, WorkItemLink
, TestRun
, and others, include the AnalyticsUpdatedDate
property. This property indicates the most recent time that the individual entity references were updated.
[!INCLUDE prerequisites-simple]
To add a column with the last refresh date of the dataset, do the following steps.
-
Load the Power BI .pbix file associated with your view in Power BI Desktop.
-
In the Queries section of the ribbon, select Transform data > Transform data.
:::image type="content" source="media/edit-queries.png" alt-text="Screenshot of Power BI Desktop, Home tab, highlighted Transform Data button in Queries section." lightbox="media/edit-queries.png":::
-
Select Advanced Editor.
:::image type="content" source="media/advanced-editor.png" alt-text="Screenshot of highlighted Advanced Editor button." lightbox="media/advanced-editor.png":::
If you didn't modify the query, review the following examples with specific table values matching your Analytics view.
let Source = AzureDevOps.AnalyticsViews("{OrganizationName}", "{ProjectName}", []), #"Private Views_Folder" = Source{[Id="Private Views",Kind="Folder"]}[Data], #"{AnalyticsViewsID_Table}" = #"Private Views_Folder"{[Id="{AnalyticsViewsID}",Kind="Table"]}[Data], #"Added Refresh Date" = Table.AddColumn(#"{AnalyticsViewsID_Table}", "Refresh Date", each DateTimeZone.FixedUtcNow(), type datetimezone) in #"Added Refresh Date"
let Source = AzureDevOps.AnalyticsViews("{OrganizationName}", "{ProjectName}", []), #"{AnalyticsViewsID_Table}" = Source{[Id="{AnalyticsViewsID}",Kind="Table"]}[Data] in #"{AnalyticsViewsID_Table}"
-
Modify the query according to the following syntax.
let Source = AzureDevOps.AnalyticsViews("{OrganizationName}", "{ProjectName}", []), #"Private Views_Folder" = Source{[Id="Private Views",Kind="Folder"]}[Data], #"{AnalyticsViewsID_Table}" = #"Private Views_Folder"{[Id="{AnalyticsViewsID}",Kind="Table"]}[Data], #"Added Refresh Date" = Table.AddColumn(#"{AnalyticsViewsID_Table}", "Refresh Date", each DateTimeZone.FixedUtcNow(), type datetimezone) in #"Added Refresh Date"
let Source = AzureDevOps.AnalyticsViews("{OrganizationName}", "{ProjectName}", []), #"{AnalyticsViewsID_Table}" = Source{[Id="{AnalyticsViewsID}",Kind="Table"]}[Data], #"Added Refresh Date" = Table.AddColumn(#"{AnalyticsViewsID_Table}", "Refresh Date", each DateTimeZone.FixedUtcNow(), type datetimezone) in #"Added Refresh Date"
[!NOTE]
These examples use UTC. You can adjust the query code based on your specific timezone as described in DateTimeZone functions. -
Select Done.
-
Select Close & Apply to immediately refresh the dataset.
:::image type="content" source="media/transform-data/powerbi-close-apply.png" alt-text="Screenshot of Power BI Desktop, Home, highlighted Close & Apply button.":::
-
From Power BI, select Get data > Blank Query.
:::image type="content" source="media/last-refresh/get-data-blank-query.png" alt-text="Screenshot of highlighted buttons, Get data, and Blank query.":::
-
Rename the query to Last Refreshed Date, and then enter the following formula into the function bar.
:::image type="content" source="media/last-refresh/last-refresh-date-query.png" alt-text="Screenshot of Power Query Editor, formula for DateTime.LocalNow for Last Refresh Date query. ":::
-
To convert the date data to a table format, choose To Table > To Table. Depending on the version you're using, you might need to Invoke parameters first.
:::image type="content" source="media/last-refresh/convert-data-to-table.png" alt-text="Screenshot of Power Query Editor, To Table option. ":::
A single column appears with the date.
:::image type="content" source="media/last-refresh/column-coverted-data.png" alt-text="Screenshot of converted date column. ":::
[!TIP] If you don't see the To Table option, you can use the following alternative steps to add the last refresh date and time to your reports:
- Select the Home tab and select Get Data. Choose Blank Query from the options.
- In the Queries pane, right-select on the new query and select Advanced Editor.
- Replace the existing code with the following code to create a table with the current date and time:
let Source = #table( {"Last Refresh Date"}, {{DateTime.LocalNow()}} ) in Source
-
From the Transform menu, select the Data Type dropdown menu and select Date/Time option.
:::image type="content" source="media/last-refresh/change-data-type-date-time.png" alt-text="Screenshot of Transform menu, Change Data Type option to Date/Time. ":::
-
Rename Column1 to something more meaningful, such as Last Refresh Date.
-
From the Home menu, select Close and Apply.
:::image type="content" source="media/transform-data/powerbi-close-apply.png" alt-text="Screenshot of Power BI Desktop, Home, Close & Apply.":::
-
To add a card with the last refresh date to your reports, under Visualizations, choose Card, and add Refresh Date or Last Refresh Date to Fields.
:::image type="content" source="media/last-refresh/card-visualizations.png" alt-text="Screenshot of Power BI Desktop, Card, Refresh Date Applied.":::
Choose Refresh to refresh report page data and the data model. After all queries are updated, the card refreshes with the latest date.
:::image type="content" source="media/last-refresh/refresh-data.png" alt-text="Screenshot of the Power BI Desktop refresh option.":::