Logical Views to specify an outer join between two attribute lookup tables when only attributes are on a report
Logical Views to specify an outer join between two attribute lookup tables when only attributes are on a report
Apart from using the VLDB properties to create the left outer join, article describes how to use the Logical View to specify an outer join between two attribute lookup tables when only attributes are on a report. This method exists as attribute only outer joins will not be generated on their own by the MicroStrategy SQL engine. This is because they are only necessary with ragged/unbalanced hierarchies which are not supported as null attribute IDs are not supported (parent elements with no child elements or child elements with no parents).
Brief instructions are provided using the example below.
Consider, two attributes: Parent01 and Child01 have a parent-child relationship. Their Lookup tables are defined, as follows
Parent01 | Child01 |
Note that although there are 4 ID values for the attribute Parent01, there is no defined relationship for the Parent01 element p4 (ID=4) in the Lookup table for attribute Child01. Placing both attributes on a report will result in the following SQL and data returned. Parent01's element p4 will not be returned. This is known as a ragged hierarchy and is not supported in MicroStrategy.
SQL | Data Returned |
select a12.parent01_ID parent01_ID, a13.parent01_DESC parent01_DESC, a12.child01_ID child01_ID, a12.child01_ID child01_ID0 from child01 a12 join parent01 a13 on (a12.parent01_ID = a13.parent01_ID) |
To overcome this issue, create a Logical View with the following SQL. Note the Left Outer Join.
SQL | Logical View Definition |
select a12.parent01_ID parent01_ID,
a12.parent01_DESC parent01_DESC, a11.child01_ID child01_ID, a11.child01_DESC child01_DESC from parent01 a12 left outer join child01 a11 on (a11.parent01_ID = a12.parent01_ID) |
Modify the attribute Child01 to include the new Logical View as a source table and redefine a relationship to attribute Parent01 using the new Logical View.
Add Source Table | Add Relationship |
Executing the same report will now return all elements for Attribute Parent01.
SQL | Data Returned |
select /* RRR01 */ a12.parent01_ID parent01_ID,
a12.child01_ID child01_ID from (select a12.parent01_ID parent01_ID, a12.parent01_DESC parent01_DESC, a11.child01_ID child01_ID, a11.child01_DESC child01_DESC from parent01 a12 left outer join child01 a11 on (a11.parent01_ID = a12.parent01_ID)) a12 |
Comments
Post a Comment