My problem seems to be determining the logic for the Feeders for "Attrition" & "Transfer Out" Balance Types.
For the "New" & "Transfer In" the Feeder seems to be working properly when referencing the Balance Type "EOP" as the rules for those Types are largly based on the EOP.
For the Attrition & Transfer Out, the Rule references a 2nd cube (Biz_Staff_Map) that is like a mapping / DB Cube that stores the historical data as String Values so that I can query if the Employees ID existed last month and / or changed Cost Centre between months. Am I correct in saying that this should be the source for my Feeder?
Below is the Code I've currently got saved in the Staff Cube Rule:
Code: Select all
# 201212 - JC Rules to Feed the Account Structure
SKIPCHECK ;
#UNDEFVALS ;
# New
['New'] = N:
# Does the SOE ID have a current Balance in any account:
If( DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,!ResponsibilityCentre,!Account,!Period,'EOP','HeadCount') <> 0 &
# Does the SOE ID have a balance in any RC last month:
DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,'Total RCs','940198PA',attrs('Period', !Period, 'Prior_Mth'),'EOP','HeadCount') = 0 %
DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,'Total RCs','940199PA',attrs('Period', !Period, 'Prior_Mth'),'EOP','HeadCount') = 0
# If True
,DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,!ResponsibilityCentre,!Account,!Period,'EOP','HeadCount')
# Else
, STET ) ;
# Attrition
['Attrition'] = N:
# Is the SOE ID missing a valid Local Code for the current month in Biz_Staff_Map2:
If ( DB('Biz_Staff_Map',!Period,!Staff,'Local Org Code') @<> ''
#If True
, STET ,
# Else
# No balance Exists in TOTAL RC's in Current Period:
If (DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,'Total RCs',!Account,!Period,'EOP','HeadCount') = 0 ,
# If True
DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,!ResponsibilityCentre,!Account,attrs('Period', !Period, 'Prior_Mth'),'EOP','HeadCount')*-1
# Else
, STET )) ;
#Transfer In
['Transfer In'] = N:
# Balance Exists in TOTAL RC's in Last Period:
If( DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,'Total RCs','940199PA',attrs('Period', !Period, 'Prior_Mth'),'EOP','HeadCount') <> 0
# % DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,'Total RCs','940199PA',attrs('Period', !Period, 'Prior_Mth'),'EOP','HeadCount') <> 0
# Balance Exists in this period:
& DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,!ResponsibilityCentre,!Account,!Period,'EOP','HeadCount') <> 0
# RC in Last Period is not the same as current Period:
& DB('Biz_Staff_Map',attrs('Period', !Period, 'Prior_Mth'),!Staff,'Local Org Code') @<> DB('Biz_Staff_Map',!Period,!Staff,'Local Org Code'),
# If True
DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,!ResponsibilityCentre,!Account,!Period,'EOP','HeadCount')
# Else
, STET ) ;
# Transfer Out
['Transfer Out'] = N:
# If Last Month EOP is 0, then there is no Transfer out!
If ( DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,!ResponsibilityCentre,!Account,attrs('Period', !Period, 'Prior_Mth'),'EOP','HeadCount') = 0 , STET ,
# Does the RC does have a valid Local Code for the current month in Biz_Staff_Map:
If (DB('Biz_Staff_Map',!Period,!Staff,'Local Org Code') @<> ''
# Is the last period RC not equal to current month RC:
& DB('Biz_Staff_Map',attrs('Period', !Period, 'Prior_Mth'),!Staff,'Local Org Code') @<> DB('Biz_Staff_Map',!Period,!Staff,'Local Org Code')
# Is the Current Month DS balance equal to 0:
& DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,DB('Biz_Staff_Map',!Period, !Staff,'Local Org Code'),!Account,!Period,'EOP','HeadCount') @= ''
# Is the Current Month DS balance not equal to 0 for current RC:
& DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,!ResponsibilityCentre,'940198PA',!Period,'EOP','HeadCount') <> 1 ,
# If True
DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,DB('Biz_Staff_Map',attrs('Period', !Period, 'Prior_Mth') ,!Staff,'Local Org Code'),!Account,attrs('Period',!Period, 'Prior_Mth'),'EOP','HeadCount') * -1 ,
# Else
# If Staff changed from Direct Staff to FTE
If ( DB('Biz_Staff_Map',attrs('Period', !Period, 'Prior_Mth'),!Staff,'Direct Staff Flag') @= 'Y' & DB('Biz_Staff_Map',!Period,!Staff,'Direct Staff Flag') @= 'N' ,
#If True
DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,DB('Biz_Staff_Map',attrs('Period', !Period, 'Prior_Mth') ,!Staff,'Local Org Code'),!Account,attrs('Period', !Period, 'Prior_Mth'),'EOP','HeadCount') * -1 ,
# If FTE Number changes between the months, there has been a transfer between being FT & PT
# If ( DB('Biz_Staff_Map',attrs('Period', !Period, 'Prior_Mth'),!Staff,'FTE') <> DB('Biz_Staff_Map',!Period,!Staff,'FTE') ,
# If True
# DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,DB('Biz_Staff_Map',attrs('Period', !Period, 'Prior_Mth') ,!Staff,'Local Org Code'),!Account,attrs('Period', !Period, 'Prior_Mth'),'EOP','HeadCount') * -1 ,
# Else
STET ))) ;
#----------------------------------------
FEEDERS;
[BalanceType: 'EOP'] => [ BalanceType: 'New'] ;
[BalanceType: 'EOP'] => [ BalanceType: 'Transfer In'] ;
#Test 1:
#[BalanceType: 'EOP'] => [ BalanceType: 'Attrition'] ;
#[BalanceType: 'EOP'] => [ BalanceType: 'Transfer Out'] ;
#Test 2:
#[BalanceType: 'EOP'] => DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,!ResponsibilityCentre,!Account,attrs('Period', !Period, 'Prior_Mth'),'Attrition','HeadCount') ;
#[BalanceType: 'EOP'] => DB('Biz_Staff2',!Version,!SectionCode,!SectionA,!SectionB,!SectionC,!Staff,!Product,!ResponsibilityCentre,!Account,attrs('Period', !Period, 'Prior_Mth'),'Transfer Out','HeadCount') ;
Since the Attrition & Transfer Out rely on the results from references back to the Biz_Staff_Map Cube, should be Feeder be looking at that Cube for my Feeder?
An example of my Biz_Staff_Map is below:

So for the employee above, they left in September and should be an attrition in my Cube in October so when looking at the leaf level I get this:

Though as soon as i use the Zero Supress, I loose my Attrition:

So the first one proves that my rule works, the 2nd is obvioulsy suggesting that I have issues with my existing Feeders (Whether I user Test 1 or Test 2 versions of their Feeders)
Any ideas on where I'm going wrong?