Data-mart KPI Development - Querying a variable depth Org Unit structure

Most reports will have an Org Unit Parameter, which may or may not be displayed to the User to enter.

The Org Unit Dim (DM_DIMORGUNIT) stores the Org Hierarchy of all Org Units that have been extracted into the Data Warehouse.

The following logic will need to be added to the Data Set Query to retrieve the correct records from the Data Mart:

where org_dim.orgunitkey in (select Org.orgunitkey
    from DM_DIMORGUNIT Org where Org.orgunitparentname is null and
    Org.orgunitid in (select T4.orgunitid from DM_DIMORGUNIT T4 where
    T4.orgunitparentname is not null and T4.orgunitparentid = ? ))

This logic returns all of the Child Org IDs that belong to the specified Parent ID. The logic may also be implemented in the From clause of the Data Set.