This project has moved and is read-only. For the latest updates, please go here.

Current Cube with Perspective

Oct 29, 2009 at 2:22 PM


     I had a problem using the Sprocs in an Action when connected to a perspective instead of directly to the cube. 

     The CurrentCellAttributes method used in a rowset action in the cube worked when connected directly to the cube, but would not expose the action when connected to a perspective.  There is no indication of what the problem is when using the browser in BIDS or Excel, but if you try to call the method in an MDX query in an "Analysis Services MDX Query" window in SSMS you get: "#Error Stored procedures errors: The CurrentCube property on the Context object cannot be used since there is no available cube context.".

     I have a quickly created workable solution, essentially hardcoding the cube name into the action query and changing the code to accomodate this, but now their should probably be a discussion about a better long term solution.

     I started a thread on this in the Analysis Services Forums:

     Someone suggested this code, which seems workable to me:

private static string GetCurrentCubeName()
            string sCubeName = "";
            if (Context.CurrentCube != null)
                sCubeName = Context.CurrentCube.Name;
                sCubeName = new Expression("[Measures].CurrentMember.Properties(\"CUBE_NAME\")").Calculate(null).ToString();

            //this code will run if the current cube is a perspective. it will return the name of the base cube in order to work around a bug in walking through the objects in AdomdServer in a perspective
            Property propBaseCubeName = Context.Cubes[sCubeName].Properties.Find("BASE_CUBE_NAME");
            if (propBaseCubeName != null)
                return Convert.ToString(propBaseCubeName.Value);
                return sCubeName;


Oct 29, 2009 at 10:21 PM
Edited Oct 29, 2009 at 10:21 PM

I've got this change integrated into the source code but haven't checked it in just yet. I'm making some other fixes and tweaks. Thanks for reporting this problem.

Nov 11, 2009 at 6:17 PM

Thanks for the SProcs, they are really a gotta have from my perspective.