Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using WITH to slice multiple members of same dimension

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
Essentially, I have a 4 dimensional cube defined with the following dimensions-
time_dimension
area_dimension
org_dimension
class_dimension
What I am building is a VB.NET form with something that looks like the SQL Server's analysis service's cube browser, with the following enhancements implemented as a tree view for each dimension:
1) Allow user to select or partially select a 'branch' (e.g. selecting the "United Kingdom" would make the "Europe" branch partially selected)
2) Display the number of 'records' currently selected. This is the *Intersection* of all selections made in all of the 4 dimensions.
3) Display the number of "records" available for selection. This is the intersection of all selections made in all of the 4 dimension, excluding the dimensions being worked on at present (i.e., If I am on the tree view for area, then selecting "United Kingdom should not limit the number of records *available* for selection)
4) A user could select multiple members (of different hirerarchy) per dimension (e.g. United Kingdom,Sydney,Asia). A selection made in one dimension(tree) could affect the number of selected/available records in 2 and 3 above.
5) The 'number' against each node in the tree list displayed for each dimension changes as user make selection in other dimension (e.g., as user select orgA in the org_dimension tree, the number against each node in area_dimension tree changes to 0 for areas where orgA is not present.
So far, I have implemented a code snippet which list a tree view for Area as follows:
Code:
        Dim cat As New ADOMD.Catalog()
        Dim cst As New ADOMD.Cellset()
        Dim i32LastLevel As Int32
        Dim i As Integer

        Dim strRowText As String
        'Array into the 'last' tree node for each level
        Dim arrTreeNode(6) As TreeNodeCollection
        Dim i16CurTreeDepth As Int16
        Dim strCurLabel As String
        Dim cnn As New ADODB.Connection()
        cnn.Open("Data Source=testDataSource;initial catalog=test;Provider=MSOLAP")

        Dim cdf As ADOMD.CubeDef

		   cat.ActiveConnection = cnn

		  'MDX Query to for listing area, assuming a previous user selection on organisation dimension
        'for [FSA_LON]
        strSource = "SELECT [are_dimension].members on COLUMNS "
        strSource = strSource & ",[time_dimension].members on ROWS "
        strSource = strSource & "FROM testdatacube "
        strSource = strSource & "WHERE (Measures.[Rre Measurement]"
        strSource = strSource & ",[FSA_LON])"

        cst.Open(strSource, cnn)

        arrTreeNode(0) = TreeView2.Nodes
		  'Loop through each element, using the LevelDepth property to work out
        'the hirerarchy
        For i = 0 To cst.Axes(0).Positions.Count - 1

            i16CurTreeDepth = cst.Axes(0).Positions(i).Members(0).LevelDepth
            If i16CurTreeDepth > 0 Then
                Dim nodDimensionNode As TreeNode = New TreeNode()
                strCurLabel = cst.Axes(0).Positions(i).Members(0).Caption
                'Display measure in brackets if it is present
                If Not (TypeOf cst(i).Value Is System.DBNull) Then
                    strCurLabel &= "   (" & CStr(cst(i).FormattedValue) & ")"
                End If
                nodDimensionNode.Text = strCurLabel



                DirectCast(arrTreeNode(i16CurTreeDepth - 1), TreeNodeCollection).Add( _
                nodDimensionNode)
                arrTreeNode(i16CurTreeDepth) = nodDimensionNode.Nodes
            End If
        Next
My queries are:
1) Is using (dynamically generated) MDX Query the only/easiest way to obtain the total available/selected reading of 2 and 3 above.
I.e.) SELECT [current_dimension].members on COLUMNS FROM testDataCube WHERE (Measures.[rre measurements], <slicer_specification>) to list the tree view for the current dimension being worked on, taking into account of selection made in other dimension

2) In particular, it appears that MDX Query does NOT allow within the <slicer_specification> slicing of multiple members of the same dimension (e.g. USA or Paris or England). It appears that I could do so with a with clause < Is this the case? Note I would be filtering on Dimension X when I am working on dimension Y. How could I use the with clause within a basic MDX syntax
Code:
SELECT [<axis_specification> [, <axis_specification>...]] FROM [<cube_specification>] [WHERE [<slicer_specification>]]

What I want is something like
List all areas in the the area dimension tree
For all records taken between February 2000 to April 2002
AND
relating to class ClassA
AND
relating to organisation orgA

3) Is there a simpler way to doing these selection then to use (dynamic MDX)? In particular, could I use the object model to 'navigate' my way through? One problem I could forsee is if I am saying navigating on one dimension, the Dimension object does not appear to have knowledge of whether how the reciords in that dimension relates to records in other dimensions.

4) I attempted to use the slicer_specification slicing on one member per dimension only when I am doing SELECT [are_dimension].members. It works on all dimension except the are_dimension (expected) and [org_dimension]. I get error &quot;duplicate dimensions across (independent) axes- when calculating
a query axis&quot;. However, after I deleted the cube and rebuilt it using the generated VB Script (which I used to create the cube in the first place), I could apply splicer_specification on [org_dimension] but not [time_dimension]!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top