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

Add new method : FindCurrentTupleNoMeasures() in FindCurrentMember.cs

Topics: Developer Forum, Project Management Forum
Mar 14, 2012 at 11:08 AM

Hello would it be possible to add this method in the FindCurrentMembe class  ? the FindCurrentTuple but with no measures useful in case of adding manually measures in mdx.

 

 

        //FindCurrentMember returns a comma-delimited list of the uniquenames of the currentmember on every attribute hierarchy
        //on every dimension but Measures
        public static string FindCurrentTupleNoMeasures()
        {
            string output = "(";
            Boolean addcomma = false;

            foreach (Dimension d in Context.Cubes[AMOHelpers.GetCurrentCubeName()].Dimensions)
            {
                // skip measures
                if (d.DimensionType == DimensionTypeEnum.Measure)
                    continue;

                foreach (Hierarchy h in d.AttributeHierarchies)
                {
                    if (d.DimensionType == DimensionTypeEnum.Measure || h.CurrentMember.UniqueName != h.DefaultMember)
                    {
                        if (addcomma == false)
                            addcomma = true;
                        else
                            output += ",";

                        output += h.CurrentMember.UniqueName;
                    }
                }
            }
            output += ",[Measures].members";

            return output;
        }

 

 

Mar 14, 2012 at 9:08 PM

Hi fpatou, can you post an example of how you would see such a feature being used? FindCurrentTuple was originally written as a debugging/educational tool. And I'm not sure what you mean by "useful in case of adding manually measures in mdx". In most cases you usually want to avoid using .net methods in measures, because of the large overhead in calling out to .net.

Mar 16, 2012 at 10:22 AM
Edited Mar 20, 2012 at 9:41 AM

SO....the idea is to implement a rowset action in a cube a cell level that can be use in excel (like a "custom drillthrought").

The Function is used to get the context of the current pivot table in excel to build a sub cube : 

Select (...) FROM (SELECT "  +  ASSP.FindCurrentTuple() + " ON 0 FROM [CUBE])

With FindCurrentTuple()  the  measures  present in the current pivot table are involve in the sub cube, then if you want to specify other measure not present in the  pivot table you have to use a "with member" before the select statement and of course you need to alias your original measures....Not really convenient. 

with such a method FindCurrentTupleNoMeasures() you don't need to alias measures....

Example :

Olap DB/cube : Adventure Works

Create a new action TEST (cell level/rowset ) :

"SELECT [Measures].[Internet Order Quantity] on 0 ,

[Product].[Category].[Category].members on 1 FROM (SELECT "+ ASSP.FindCurrentTuple()+ " ON 0 FROM [Adventure Works])"

 

And let say you have a excel pivot table with [Product category] and [Internet Order Count].....runing the action won't return [Measures].[Internet Order Quantity] unless you specify this in the action...

"with member Measures.[MY Internet Order Quantity] as [Measures].[Internet Order Quantity]

SELECT Measures.[MY Internet Order Quantity] on 0 ,

[Product].[Category].[Category].members on 1 FROM (SELECT "+ ASSP.FindCurrentTuple()+ " ON 0 FROM [Adventure Works])"

THEN this is not very convenient......!!!!

With the method  FindCurrentTupleNoMeasures() you can use directly the name of the original Measures....

"SELECT Measures.[Internet Order Quantity] on 0 ,[Product].[Category].[Category].members on 1 FROM (SELECT "+ ASSP.FindCurrentTupleNoMeasures()+ " ON 0 FROM [Adventure Works])"

Conclusion :

This make sens if the query is used with many measures (more simple to write) and cube users are used to original measures name... then for business purpose alias measures is confusing.....(Finance manufacturing and so on....).

Hope this is clear....:-)

 

PS : In excel fields are retreived with the extension ."MemberCaption"...like [Product].[Category].[Category].MemberCaption....is it possible to get rid off the suffix ?