Feeding One Cube from Another

Things become a little more difficult when you need to write feeders for inter-cube calculation statements, such as the calculation statements in the rule for the Inventory cube that retrieve values from the Purchase cube.

As you recall, the calculation statements are relatively simple. Residing in the rule for the Inventory cube, they look like this:

['1','Quantity in Stock - Kgs']= N:DB('Purchase',!FishType,'Total Markets',!Date,'Quantity
Purchased - Kgs');['1','Purchase Cost'] = N:DB('Purchase',!FishType,'Total
Markets',!Date,'Price/Kg - USD');

The feeders for these statements are simple, but they must reside in the rule for the Purchase cube, not the Inventory cube. When working with inter-cube rules, calculation statements reside in the target cube, while feeder statements always reside in the source cube.

The following example guides you through the creation of feeder statements for the Inventory cube.

Procedure

  1. Open the rules for both the Inventory and Purchase cube.

    When creating inter-cube feeders, for best practice, have the Rules Editor for both the source cube and target cube open in your workspace.

  2. Position the cursor at the beginning of a new line after the last feeder statement in the Purchase rule.
  3. Enter the following text:
    #Feeders for the Inventory cube follow

    This line is a comment that makes the rule more understandable.

  4. On a new line beneath the comment, enter the following feeder statement, either by typing or by using the toolbar buttons in the Rules Editor:
    ['Total Markets','Quantity Purchased - Kgs']=>DB('Inventory',!FishType,!Date,'
    1','Quantity in Stock - Kgs');

    This feeder statement ensures that any location in the Purchase cube identified by the elements Total Markets and Quantity Purchased - Kgs feeds the analogous location in the Inventory cube identified by the elements 1 and Quantity in Stock - Kgs.

    The feeder is basically the inverse of the calculation statement in the Inventory cube that requires the feeder:

    ['1','Quantity in Stock - Kgs']= N:DB('Purchase',!FishType,'Total
    Markets',!Date,'Quantity Purchased - Kgs');
  5. On a new line below the feeder statement you just created, enter the next feeder statement:
    ['Total Markets','Price/Kg - USD']=>DB('Inventory',!fishtype,!date,'1','Purchase
    Cost');

    Again, note that this feeder statement is the inverse of the calculation statement that requires the feeder:

    ['1','Purchase Cost'] = N:DB('Purchase',!FishType,'Total Markets',!Date,'Price/Kg
    - USD');

    The Rules Editor for the Purchase rule should now appear as follows:

    SKIPCHECK;
    ['Purchase Cost - LC']=N:['Quantity Purchased - Kgs']*['Price/Kg
    -LC'];
    ['Price/Kg - USD']=['Price/Kg - LC']\DB('CurrencyExchangeRate',DB('Currency',!market,'
    MarketCurrency'),!date);
    ['Purchase Cost - USD']=N:['Purchase Cost - LC']\DB('CurrencyExchangeRate',
    DB('Currency',!market,'MarketCurrency'),!date);
    FEEDERS:
    ['Quantity Purchased - Kgs']=N:['Purchase Cost - LC'];
    ['Price/Kg - LC']=>['Price/Kg - USD'];
    ['Purchase Cost - LC']=>['Purchase Cost - USD']'
    #Feeders for the Inventory cube follow
    ['Total Markets','Quantity Purchased - Kgs']=>DB('Inventory',!FishType,!Date,
    '1','Quantity in Stock - Kgs');
    ['Total Markets','Price/Kg - USD']=>DB('Inventory',!fishtype,!date,'1','Purchase
    Cost');
  6. Click Save in the Rules Editor for the Purchase rule.