Skip to main content

Restricting the Records Used in the Cube

Restricting the Records Used in the Cube

By default, the system uses all the records in the source class. You can modify the cube definition so that some of the records are ignored. You can do this in either or both of the following ways:

%OnProcessFact() Callback

To ignore some of the records of the base table and not include them in the cube, you can define the %OnProcessFact() method in your cube definition class:

classmethod %OnProcessFact(pID As %String, ByRef pFacts As %String,         Output pSkip As %Boolean, pInsert As %Boolean) as %Status

The system calls this method immediately after accessing each row in the base table, when building or updating the fact table. It passes the following values to this method:

  • pID is the ID of the row in the source data being processed.

  • pFacts is a multidimensional array that contains the values that will be used for the row. This array has the following structure:

    Node Value
    pFacts(factName) where factName is the name of the level or measure in the fact table, as specified by the Field name in fact table option. Value of that level or measure. For example, Magnolia or 47.
  • pInsert is 1 if this is a new row.

If you want to skip this record, your method should set pSkip to true; otherwise it should set pSkip to false.

For example, the following callback causes the cube to ignore all patients whose favorite color is blue:

ClassMethod %OnProcessFact(pID As %String, ByRef pFacts As %String, 
Output pSkip As %Boolean, pInsert As %Boolean) As %Status
{
    if pFacts("DxColor")="Blue"
    {
        set pSkip=1 
    } else {
            set pSkip=0
            }
     quit $$$OK
}

This example assumes that the cube defines the Field name in fact table option as DxColor for the favorite color level.

Note:

If your %OnProcessFact() evaluates records based on the levels or measures you specify using the pFacts array, you must include the corresponding cube elements whenever you perform a Selective Build for the cube. In the preceding example, the user must include DxColor in any Selective Build for the cube. Otherwise, every record will yield an error because the value of pFacts(“DxColor”) will be undefined.

For another example, the following callback would cause the cube to ignore all records whose ID was less than 1000000:

ClassMethod %OnProcessFact(pID As %String, ByRef pFacts As %String, 
Output pSkip As %Boolean, pInsert As %Boolean) As %Status
{
    if pID<1000000
    {
        set pSkip=1 
    } else {
            set pSkip=0
            }
     quit $$$OK
}
FeedbackOpens in a new tab