Get SSAS cube last process time

心不动则不痛 提交于 2020-01-02 08:45:15

问题


In Excel I make an Analysis Services connection to a data cube. I would like to be able to show a user how current the data is by showing them when the last cube processing time occurred. Making an analysis services connection to the cube in SQL Server Management Studio (SSMS), I can right click on the cube and see the property of the last cube processing time exists. I can also create an MDX query as follows to return the last process time:

SELECT LAST_DATA_UPDATE FROM $system.mdschema_cubes

I would like to be able to retrieve this same information in Excel whether it is via VBA or some other method as long as it can be done in Excel without some external tool.


回答1:


I actually found a way to do it in Excel without having to create any views or new measures. In Excel 2013, PowerPivot allows you to create your own custom MDX queries against a cube. You can open PowerPivot, make the connection to your cube, paste in the MDX query I used in SSMS to return the cube process time,

SELECT LAST_DATA_UPDATE FROM $system.mdschema_cubes

and then export this to a pivot table. I did not need to modify anything outside of Excel. Here is a document with step by step procedures.




回答2:


I had the same need on a project, to show cube last processed date/time in Excel. This may be a little hokie but it definitely works. I added a query against my database in my DSV (technically I made a view since all of my source data came from views rather than named queries or tables) that was just

Select CURRENT_TIMESTAMP as CubeLastRefreshed

I made it a dimension that is related to nothing. Then users can pull it into Excel. You can make a pivot table with just that in it. Or you can write a cube function in Excel to show it at the bottom of the report. It would look something like

=cubemember("Cube","[Cube Process Date].[Cube Last Processed].firstchild")

Just make sure to pay attention to when this dimension gets processed. If you only process certain dimensions or measures on certain days, make sure processing of this dimension is included in the correct places.




回答3:


You could use the CubeInfo procedures from the AS StoredProcedures project on Codeplex. You would have to deploy the assembly that you can download there to your server, and then define measures similar to those described in the WITH clauses of the query at the bottom of the above referenced page.

All the source code of the stored procedures is available at CodePlex as well.




回答4:


I use the following VBA to place current date-time into a cell in the spreadsheet whenever any pivot table (which includes those populated from SSAS) is updated:

Private Sub Workbook_SheetPivotTableUpdate(ByVal Sh As Object, ByVal Target As PivotTable)
Range("Documentation!B3").Value = Now()
End Sub

This captures the time when the spreadsheet extracted data from the cube rather than the time the cube was processed, but perhaps may be of some help to you.



来源:https://stackoverflow.com/questions/19942196/get-ssas-cube-last-process-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!