The Result Data Newsletter   
Volume 804 - April 2008   
© Copyright 2008 Result Data Consulting, Ltd.  614-505-0770  www.resultdata.com   

    Result Data Home Page  |  Newsletter Archive  |  Upcoming Events  |  Classes & Workshops  |  Request Information
Upcoming Events:  Mid Ohio BusinessObjects User Group: 5/20, Discover the Power of BusinessObjects XI 3.0:  5/20

Return to Newsletter Contents...

Performance Management

by: Aaron Zechman, BI Consultant, CRCP, BOCP, MCSE

“Look before you leap.”

“Don’t put all your eggs in one basket.”

“Look both ways before you cross the street.”

What is the common theme between all these quotes?  No, it’s not things my mom said to me growing up.  It is that all these quotes provide words of caution.  Caution that should be taken into consideration when developing universe objects especially when using the WHERE clause.  Now you might say why do I need to use caution using the WHERE clause, let me explain.

Pic 1

Now let us say that the SALE_TYPE in the SALE table contains ‘S’ and ‘R’ where S is for Sales and R is for Rental.  We want to calculate the revenue for both sales and rentals.

 The sales revenue is calculated as:

SUM(SALES_MODEL.SALE_QTY * MODEL.MODEL_PRICE * ((100 – SALE.SALE_SALE_DISCOUNT)/100))

The rental revenue is calculated as:

SUM(SALE.SALE_RENTAL_PERIOD * SALE_MODEL.SALE_QTY * MODEL.MODEL_DAYRENT * ((100 – SALE.SALE_SALE_DISCOUNT)/100))

Now if we create a measure, for Sales Revenue, using the where clause it may look like the following:

Pic 2

Now the Rental Revenue would have its calculation and the only things that are changed is the sales revenue and in the where clause there will be SALE.SALE_TYPE = ‘R’.

The problem with this is not when you use either the Sales Revenue or the Rental Revenue individually; it is when you drag both of the measures onto the query panel.  It would give you the following code:

SELECT DISTINCT

  SUM(SALE.SALE_RENTAL_PERIOD*SALE_MODEL.SALE_QTY*MODEL.MODEL_DAYRENT*((100-SALE.SALE_SALE_DISCOUNT)/100)),

  SUM(SALE_MODEL.SALE_QTY*MODEL.MODEL_PRICE*((100-SALE.SALE_SALE_DISCOUNT)/100))

FROM

  SALE INNER JOIN SALE_MODEL ON (SALE.SALE_ID=SALE_MODEL.SALE_ID)

   INNER JOIN MODEL ON (SALE_MODEL.MODEL_ID=MODEL.MODEL_ID)

WHERE

( SALE.SALE_TYPE='R'  )

  AND  ( SALE.SALE_TYPE='S'  )

Now we can see the inherent problem with this is the WHERE clause if both measures are on the report.  The SALE.SALE _TYPE will never be both ‘R’ and ‘S’ at the same time so this will bring us back an empty result set or zero records.

Now you are asking how we might solve this problem.  It is not too difficult using the case statement.  Now the case statement is formed like the following:  CASE WHEN THEN END.  Let us redo the measure object for Sales Revenue using the case statement instead of the WHERE clause.  It should look something like the following:

Pic 3

Now notice I removed the where clause and used it in the case statement.  When the SALE.SALE_TYPE is ‘S’ it is going to perform the calculation otherwise it is going to add zero to the total giving us the total sales revenue.  Now we will need to repeat this same process for the Rental Revenue.  Now when this is done if both measures are dragged out into the query panel we will get the following SQL statement that is created:

SELECT DISTINCT

  SUM(

  CASE

    WHEN SALE.SALE_TYPE = 'R' THEN

      SALE.SALE_RENTAL_PERIOD*SALE_MODEL.SALE_QTY*MODEL.MODEL_DAYRENT*((100-SALE.SALE_SALE_DISCOUNT)/100)

    ELSE

        0

    END

),

  SUM(

  CASE

    WHEN SALE.SALE_TYPE = 'S' THEN

       SALE_MODEL.SALE_QTY*MODEL.MODEL_PRICE*((100-SALE.SALE_SALE_DISCOUNT)/100)

  ELSE

       0

  END

)

FROM

  SALE INNER JOIN SALE_MODEL ON (SALE.SALE_ID=SALE_MODEL.SALE_ID)

   INNER JOIN MODEL ON (SALE_MODEL.MODEL_ID=MODEL.MODEL_ID)

Now we can see that this query does not produce a where clause and that it is taken care of in the CASE statement and now the measures can coexists peacefully together.

So remember when you are designing you next universe, it is WHAT you know and not WHERE you know.

Go to Top  |  Return to Newsletter Contents

The Result Data Newsletter is published approximately once a month to share the latest information on business intelligence, data management and CRM. There should be a link below to allow you to change or remove yourself from our list. We take your requests very seriously. If you have any difficulty please contact us at 614-505-0770 and we will make sure that your request is handled properly. This is not intended to be an unsolicited message and you can reach us in person if needed.

© Copyright 2007 Result Data Consulting, Ltd. - All Rights Reserved
All trademarks and copyrights are the property of their respective owners. This information is provided without warranty.
Announcements
Save Big $$ On Gas This Spring
Schedule and attend any one of our qualifying public training classes from April through June 30th to receive up to $385 in gas cards OR  receive 10% off the normal class price.  Please contact our office for further details on promotion amounts and qualifying classes.   Restrictions apply and you must mention the promotional code Gas08 at the time of registration to receive the promotion.  Call 614-505-0770 for further details and restrictions.
Columbus Roadshow - Discover the power of BusinessObjects XI 3.0
See how you could put complete, trustworthy business intelligence into the hands of all of your people wherever their location.  This event will be held on May 20, 2008 at the Fawcett Center.  Call 614-505-0770 or click here for more information and to reserve your seat.
Mid Ohio BusinessObjects User Group
Join us for the Spring MOBOUG User Group meeting on May 20th. Call 614-505-0770 or click here for more information and to reserve your seat.
Looking for a Few Good Men and Women
Join our award winning team of Business Intelligence consultants and .Net Software developers.
Send your resume and salary requirements to:
jobs@resultdata.com