Extensions of the ConditionStep
class implement specific behavior for each type of step that is based on a condition. The following list describes these extensions.
AllStep
-- Specifies members based on levels in a hierarchy, such as All Products for the default hierarchy at the top level.
AttributeStep
-- Specifies members based on an attribute, such as Color is Red.
BasicFamilyStep
-- (Abstract). See Creating Family Steps.
FirstLastStep
-- Specifies a specified number of first or last members, such as Last 3 Quarters.
MatchStep
-- Specifies members based on the way in which members match a specified string of characters, such as Name begins with "abc".
MeasConditionStep
-- (Abstract). See Creating Measure Condition Steps.
RangeTimeStep
(applies only to Time dimensions) -- Specifies members based on a range of time, such as 4 quarters before January 2000.
To use a step, you must add it to a Selection
object and then apply the Selection
object to a query.
Select the Divisions (in Level 1 of the Standard hierarchy) and the Components (in Level 2 of the Standard hierarchy) for the Product dimension.
//strProductDim is the unique identifier of the Product dimension //strStandardHier is the unique identifier of the Standard product hierarchy //level_1 is the unique identifier of Level 1 in the Standard hierarchy //level_2 is the unique identifier of Level 2 in the Standard hierarchy // Vector m_levels = new Vector (); m_levels.addElement (level_1); m_levels.addElement (level_2); // Selection sel = new Selection (strProductDim); sel.setHierarchy (strStandardHier); AllStep allStep = new AllStep (strProductDim, strStandardHier, m_levels); sel.addStep (allStep);
Select members of the Product dimension that have the colors RED or GREEN.
//strProductDim is the unique identifier of the Product dimension // Vector attribValues = new Vector (); attribValues.addElement ("RED"); attribValues.addElement ("GREEN"); // Selection sel = new Selection (strProductDim); sel.setHierarchy (strStandardHier); AttributeStep attrStep = new AttributeStep (strProductDim, null, null, "COLOR", attribValues, AttributeStep.OP_EQUAL); sel.addStep (attrStep);
Keep the last three months in a Time selection.
//strTimeDim is the unique identifier of the Time dimension//strStandardHier is the unique identifier of the Standard product hierarchy//level_1 is the unique identifier for Level 1 of the Standard hierarchy//sel is an existing Selection object//FirstLastStep firstLastStep = new FirstLastStep (strTimeDim, strStandardHier, level_1, FirstLastStep.LAST, new Integer (3));firstLastStep.setAction (Step.KEEP);sel.addStep (firstLastStep);
Select all products with a name that begins with the letters "abc".
//strProductDim is the unique identifier of the Product dimension //strStandardHier is the unique identifier of the Standard hierarchy // Selection sel = new Selection (strProductDim); sel.setHierarchy (strStandardHier); MatchStep matchStep = new MatchStep (strProductDim, strStandardHier, null, MatchStep.BEGINS_WITH, "abc"); sel.addStep (matchStep);
Select six months starting with January, 2002.
//strTimeDim is the unique identifier for the Time dimension //strStandardHier is the unique identifier of the Standard Time hierarchy //strLevel_3 is the unique identifier of month level for the Time hierarchy // Vector monthLevel = new Vector (); monthLevel.addElement (strLevel_3); // try { Selection sel = new Selection (strTimeDim); sel.setHierarchy (strStandardHier); RangeTimeStep rangeTimeStep = new RangeTimeStep (strTimeDim, strStandardHier, monthLevel, new Integer (6), RangeTimeStep.START_WITH, "Jan2002"); sel.addStep (rangeTimeStep); } catch (Exception e) { logException (e); }