Time Filter Expression Use Cases.  

Example 1:  Apply Time Filter Expression for first two months of first year in cube.

 

 

 


TimeFilterFirstLastPeriodsExpression expression = new TimeFilterFirstLastPeriodsExpression();
expression.setWhatToCompare(tdi); <<== where tdi is YQMD
expression.setLevelName([Time].[YQMD].[Month_Name]);
expression.setSearchDirection(TimeFilterExpression.FORWARD);
expression.setnPeriods(2);
FilterItem filterItem = ds.newFilterItem();
filterItem.setLabel("Test Time");
filterItem.setDescription("Test Using '" + expression + "'");
filterItem.setExpression(expression);
ds.addBusinessItem(filterItem);
ds.setFilters(Arrays.asList(new FilterItem[] { filterItem}));

Example 2:  Apply Time Filter on 2 Parallel Periods starting from 1998Q1.February and moving forward

TimeFilterNParallelPeriodsExpression expression =  new TimeFilterNParallelPeriodsExpression();
expression.setWhatToCompare(tdi);
expression.setLevelName([Time].[YQMD].[Month_Name]);

expression.setSearchDirection(TimeFilterExpression.FORWARD);
expression.setDateMember([Time].[YQMD].[All YQMD].[1998].[1998Q1].[February]);
expression.setnPeriods(2);
assertEquals(checkForNoReasonsUnusable(expression), true);
FilterItem filterItem = ds.newFilterItem();
filterItem.setLabel("Test");
filterItem.setDescription("Test Using '" + expression + "'");
filterItem.setExpression(expression);
ds.addBusinessItem(filterItem);
ds.setFilters(Arrays.asList(new FilterItem[] { filterItem}));