We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Get dimension members from OlapDataManager

Hi,
I can get all dimensions, measures etc from the OlapDataManager by using "CurrentCubeSchema".

But what if I would like to populate listboxes with memebers from each dimension? Or a listbox with all measures available?

Is it possible to get a collection of memers similar to this (not working) code;

  foreach (var dim in olapDataManager.CurrentCubeSchema.Dimensions)
            {
                foreach (var members in dim.Members)
                {
                    DataListBox.Items.Add(members.Caption);
                }

            }

Or any other alternative?
/Erik

4 Replies

JA Jesus Arockia Sankaran S Syncfusion Team July 1, 2013 12:29 PM UTC

Hi Erik,

 

We would like to inform you that we cannot directly get the Dimension members from Dimension Collection. Dimension Collection have list of hierarchies each of which has list of levels each of which has list of members.

 

1.If you would like to populate the listbox only with dimension names, the following code can be used.

 

foreach (var dim in olapDataManager.CurrentCubeSchema.Dimensions)

            {

              foreach (var hyrar in dim.Hierarchies)

                {

                      DataListBox.Items.Add(hyrar.UniqName);

                }

                        }

 

2.If you would like to populate the listbox with level names only, the following code can be used.

 

foreach (var dim in olapDataManager.CurrentCubeSchema.Dimensions)

            {

                foreach (var hyrar in dim.Hierarchies)

                {

                    foreach (var level in hyrar.Levels)

                                                   {

                                                       DataListBox.Items.Add(level.UniqName);

                       }

                }

            }

 

3.If you would like to populate the listbox with members only, the following code can be used.

 

foreach (var dim in olapDataManager.CurrentCubeSchema.Dimensions)

            {

                foreach (var hyrar in dim.Hierarchies)

                {

                    foreach (var level in hyrar.Levels)

                    {

                        foreach (var members in level.Members)

                        {

                            DataListBox.Items.Add(members.Caption);

                        }

                    }

                }

 

            }

 

 

 

Kindly let me know if you have any concerns.

 

Regards,

Jesus Arockia Sankaran

 



EL Erik Lidman July 1, 2013 08:09 PM UTC

Hi,
Fantastic! It's possible to do everything without writing a single mdx query!

Follow up question:
In your example we see that it is possible to very easy retrive the members of a level, of a dimension. Perfect.

Is it possible to limit the returned members based on other filters in in current selection / executed MDX?

Example: The user select to filter and only see the sales data for 2006 in a cube (filter on some "date dimension"). Not all customers (members in customer dimension) has purchased anything during 2006. Say that there are totally 2000 customers in the customer dimension. But only 500 members have some sales records during 2006. In your example I get all 2000 customers as members which is fine. But I would like select to only get the 500 customer members with sales for 2006... I.e. the filters set on other dimensions should limit the returned collection of the members for the customer dimension.

/Erik


JA Jesus Arockia Sankaran S Syncfusion Team July 2, 2013 12:22 PM UTC

Hi Erik,

We would like to let you know that, by using the currentcubeschema.Dimensions, we can only select members from a single dimension. Because we can only retrieve the schema information at this point, the data will be retrieved after generating MDX query internally.

Selecting or filtering members by using different dimension is not possible in this method. For those things we have to go for MDX query or OlapReport.

Thanks for your interest.

Please let me know if you have any concerns.

Regards,

Jesus Arockia Sankaran S



NA Narayan June 9, 2014 02:11 PM UTC

Please share with me the code to load OLAP client from stream

Loader.
Live Chat Icon For mobile
Up arrow icon