Derived Attribute is the New Custom Group

There’s always delicate balance, when developing a MicroStrategy Schema, on when to know to build an auxiliary object in MicroStrategy and when to push that work to the ETL/Database.


Most of us must have faced situation when there is need of virtual attribute and Database developers are busy to provide attributes in desired format directly in database or business requirements are different for one particular user or group.



In this situations we generally opt for Custom groups which impacts performance drastically.
Ø  Each Custom Group element is a separate filter and generally creates a separate pass of SQL.
Ø  Multiple Custom Groups on a report end up multiplying by each other in regards to the number of passes of SQL.  So if you have a Custom Group with 10 elements, and a 2nd Custom Group with 10 elements, that’s 100 passes of SQL times however many passes the Metrics on the report create.


With 10 version of MicroStrategy, we can create derived attribute to address requirements which can be accomplished with custom groups. Potential of powerful analytical engine is used in correct way.


Note: Derived attributes can’t be created if dataset contains custom group. I am not sure about the logical reasoning behind this but I think MicroStrategy don’t want to keep two swords in same scabbard J


Below are steps to create Derived attribute with if or Case condition.

1
1)    Select relevant dataset and click create attribute.




























2.Determine the attribute form on which if condition needs to be applied.
3. If attribute form is missed or incorrect attribute form is used, you will get syntax error.
4. Use below syntax to create attribute with IF Condition
     If([<attribute name>]@[<attribute form>] <Condition>,”True Value”,”False Value”)


Example IF:


        Consider report with country, region, city and revenue
         You have below requirement.


Zone
Region
High
Central
Mid Atlantic
NorthEast
Low
Rest of the Regions




Attribute form for Region is ID




Output would be :
















  1. Use below syntax to create attribute with Case condition:
    Case (Condition1, ReturnValue1, Condition2,ReturnValue2,..., DefaultValue)
    For Example:

Zone
Region
High
Central
Mid Atlantic
NorthEast
Medium
South
Southeast
Southwest
Low
Rest of the Regions

Case (Region@IDin(4, 2, 1), "High", Region@IDin(5, 3, 7), "Medium", "Low")


Output:

        



Note: Apply simple can be also used  to achieve same but this option will involve access to developer and architect role
                                                                       


Comments

Post a Comment

Popular posts from this blog

The count distinct adventure - Part I

The surrogate key strikes back

The count distinct adventure - Part II