Page 1 of 1

subset creation moved to epilog and worked

Posted: Mon Aug 14, 2017 2:13 pm
by Analytics123
Hi Guys,

I had an issue with subset creation and when I moved a part of code to epilog it started working. Can you tel me if there was anything wrong having the code in prolog itself .

Prolog : Creating a subset through a mdx statement .
Subset Name : ALL X Customers

Now with All X customers subset as reference creating an another subset with some filter add to it .

vSize = SUBSETGETSIZE( vDimensionName, vSourceSubset );
WHILE( vSize > 0 );
vElement = SUBSETGETELEMENTNAME( vDimensionName, vSourceSubset, vSize );
vCustomerGrade = CELLGETS( 'AR History', vElement, 'US01', vPeriod, 'All Currencies', 'Local Currency', '120000', 'All Customer Types', 'Letter Grade' );

IF( vCustomerGrade @= 'F' );
SUBSETELEMENTINSERT( vDimensionName, vSubsetName, vElement, 1 );
ENDIF;

vSize = vSize - 1;
END;

Now both these subsets work great . I now add a third subset below this line of code in prolog which is also built from the 1 st subset as a base .

vSubsetName = 'All Y customers';
vSourceSubset = 'ALL X Customers';
vDimensionName = 'Customers SoldTo';
vSourceDim = 'Customers SoldTo Only';

IF( SUBSETEXISTS( vDimensionName, vSubsetName ) = 1 );
SUBSETDELETEALLELEMENTS( vDimensionName, vSubsetName );
ELSE;
SUBSETCREATE( vDimensionName, vSubsetName );
ENDIF;

vSize = SUBSETGETSIZE( vSourceDim, vSourceSubset );
WHILE( vSize > 0 );
vElement = SUBSETGETELEMENTNAME( vSourceDim, vSourceSubset, vSize );

IF( DIMIX( vDimensionName, vElement ) = 0 );
ITEMREJECT( 'The Specified Customer DNE in the Customers SoldTo Dimension: ' | vElement );
ELSE;
SUBSETELEMENTINSERT( vDimensionName, vSubsetName, vElement, 1 );
ENDIF;

vSize = vSize - 1;
END;



Now the subset All Y customers is partially created when the code is in prolog and is fully created when the code is in epilog(bold code in epilog now) .

Is the reference of the main subset not released in pro log . Not sure why this is happening .

Any suggestions are welcome .

Re: subset creation moved to epilog and worked

Posted: Mon Aug 14, 2017 7:06 pm
by Wim Gielis
ITEMREJECT in the Prolog tab is not the correct function here for you, I guess, given that it's the Prolog tab ?

Re: subset creation moved to epilog and worked

Posted: Mon Aug 14, 2017 8:14 pm
by Analytics123
let me check .

Thanks

Re: subset creation moved to epilog and worked

Posted: Tue Aug 15, 2017 6:26 am
by lotsaram
Wim Gielis wrote: Mon Aug 14, 2017 7:06 pm ITEMREJECT in the Prolog tab is not the correct function here for you, I guess, given that it's the Prolog tab ?
ItemReject on the Prolog is quite fine. It is just that as Prolog has no data source and executes only 1x that the ItemReject will skip the rest of the Prolog code from that point.

Re: subset creation moved to epilog and worked

Posted: Tue Aug 15, 2017 6:35 am
by Wim Gielis
lotsaram wrote: Tue Aug 15, 2017 6:26 am
Wim Gielis wrote: Mon Aug 14, 2017 7:06 pm ITEMREJECT in the Prolog tab is not the correct function here for you, I guess, given that it's the Prolog tab ?
ItemReject on the Prolog is quite fine. It is just that as Prolog has no data source and executes only 1x that the ItemReject will skip the rest of the Prolog code from that point.
That's what I meant indeed. Potentially a lot of elements in the subset are skipped.

Re: subset creation moved to epilog and worked

Posted: Tue Aug 15, 2017 12:08 pm
by Analytics123
Yes that was the issue . Thanks All !!