Tuesday, January 08, 2019

Power BI Did you know - Series 2 (Add Refresh Date )

Did you know that you can add a refresh date to indicate when your data has been last refreshed ?

Below are the steps to do this.


  • Open the report in Power BI Desktop
  • Go to Edit Queries from the Home ribbon as shown below


  • From the Power Query editor, choose the table where you would like to add the refresh date and click on Advance Editor as shown below

  • Add the below code before the in statement 
 #"Added Refresh Date" = Table.AddColumn(#"Renamed Columns", "Refresh Date", each DateTimeZone.FixedUtcNow(), type datetimezone)

  • Replace "Renamed Columns" from the above code to the name that is mentioned just above the line as shown below




For example if the below code is in the Advanced Editor, the "Removed Columns" in the step need to replace the "Renamed Columns" as shown below

let
    Source = Sql.Databases("localhost"),
    table1 = Source{[Name="table1"]}[Data],
    dbo_table = table1 {[Schema="dbo",Item="table"]}[Data],
    #"Removed Columns" = Table.RemoveColumns(dbo_table,{"col2", "col4", "col6"}),
    #"Added Refresh Date" = Table.AddColumn(#"Removed Columns", "Refresh Date", each DateTimeZone.FixedUtcNow(), type datetimezone)
in
    #"Added Refresh Date"


  • This will create a new column named Refresh Date in the table.
  • Close and Apply changes.



  • Now create a new measure, in order to add the last refresh date to the report 
  • An example code for the new measure could be as below


Footer = CONCATENATE("Last Refreshed " , MAX(Schedule[Refresh Date]))

Use a card visual to display the measure as shown below


There you go, you have the last refreshed date in your report

1 comment:

James Zicrov said...

I feel Power BI is the most useful and powerful tool which helps break out every problem categorically and separately folding itself to find solutions.

Powerbi Read Rest



Navigating the Data Science Seas: A Journey with Microsoft Fabric

Data science is a vast and exciting field, brimming with the potential to unlock valuable insights. But like any seafaring voyage, navigatin...