Skip to content

Instantly share code, notes, and snippets.

@data-goblin
Last active February 27, 2022 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save data-goblin/905dbc795e4d1adacfeb3318bd3f2c8e to your computer and use it in GitHub Desktop.
Save data-goblin/905dbc795e4d1adacfeb3318bd3f2c8e to your computer and use it in GitHub Desktop.
/////////////////////////////////////////////////////////////////////////////////////////////
//
// Evaluates a DMV to determine the last time the model was processed (refreshed)
//
// Original method from Marco Russo https://www.sqlbi.com/articles/last-process-date-in-ssas-tabular/
//
/////////////////////////////////////////////////////////////////////////////////////////////
// Query to be evaluated
string _dmv = "SELECT TOP 1 [LAST_DATA_UPDATE] FROM $SYSTEM.MDSCHEMA_CUBES";
// Evaluate the query
using(var daxReader = ExecuteReader(_dmv))
{
// Read the results
while(daxReader.Read())
{
var rowValues = new object[daxReader.FieldCount];
daxReader.GetValues(rowValues);
var row = rowValues.Select(v => v == null ? "" : v);
// Convert the scalar value to a string
string _processdate = row.ElementAt(0).ToString();
Info ( "The model was last processed at " + _processdate);
}
// Close the reader
daxReader.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment