Dave
Dave

Reputation: 5049

Showing Cube's last process time in Report

Is there any way to show the last time a Cube or a Dimension was last processed in a Report (I'm using Report Builder)?

I attempted this by starting off creating a table called LastProcessTime with the fields "Type", and "DateTimeProcessed", and I could Insert into this table, but I do not know how I would initiate the Insert. Perhaps there is an entirely different approach. Thanks.

Upvotes: 4

Views: 7086

Answers (2)

Preet Sangha
Preet Sangha

Reputation: 65555

Bit late I know - but you can use custom stored procedures in SSAS to expose this info via normal members

with 
     member [Measures].[LastProcessed] as ASSP.GetCubeLastProcessedDate()
select 
     [Measures].[LastProcessed] on 0
from [Your Cube]

These are available from CodePex : Analysis Services Stored Procedure Project,

/*============================================================================
  File:    CubeInfo.cs

  Summary: Implements a function which returns the date when the current cube
           was last processed.

  Date:    July 12, 2006

  ----------------------------------------------------------------------------
  This file is part of the Analysis Services Stored Procedure Project.
  http://www.codeplex.com/Wiki/View.aspx?ProjectName=ASStoredProcedures

  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  PARTICULAR PURPOSE.
===========================

=================================================*/

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AnalysisServices.AdomdServer;
using Microsoft.AnalysisServices; //reference to AMO

namespace ASStoredProcs
{
    public class CubeInfo
    {
        //the assembly must be registered with unrestricted permissions for this function to succeed
        [SafeToPrepare(true)]
        public static DateTime GetCubeLastProcessedDate()
        {
            string sServerName = Context.CurrentServerID;
            string sDatabaseName = Context.CurrentDatabaseName;
            string sCubeName = AMOHelpers.GetCurrentCubeName();

            DateTime dtTemp = DateTime.MinValue;
            Exception exDelegate = null;

            System.Threading.Thread td = new System.Threading.Thread(delegate() 
            {
                try
                {
                    Microsoft.AnalysisServices.Server oServer = new Microsoft.AnalysisServices.Server();
                    oServer.Connect("Data Source=" + sServerName);
                    Database db = oServer.Databases.GetByName(sDatabaseName);
                    Cube cube =  db.Cubes.FindByName(sCubeName);

                    dtTemp = cube.LastProcessed;
                }
                catch (Exception ex)
                {
                    exDelegate = ex;
                }
            }
            );
            td.Start(); //run the delegate code
            while (!td.Join(1000)) //wait for up to a second for the delegate to finish
            {
                Context.CheckCancelled(); //if the delegate isn't done, check whether the parent query has been cancelled. If the parent query has been cancelled (or the ForceCommitTimeout expires) then this will immediately exit
            }

            if (exDelegate != null) throw exDelegate;

            return dtTemp;
            //return Context.CurrentCube.LastProcessed; //this doesn't work because of a bug: https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=124606
        }
.
.
.

Upvotes: 2

Meff
Meff

Reputation: 5999

Not sure you could add this into report builder, but try a standard MDX report, and use the SSAS DMVs (Dynamic Management Views):

http://dwbi1.wordpress.com/2010/01/01/ssas-dmv-dynamic-management-view/

Run this in an MDX query window against a cube (I know, it does look like TSQL):

SELECT * FROM $system.mdschema_cubes

Should give you what you need?

Upvotes: 8

Related Questions