Top Banner
Ranking in BusinessObjects Reports Maja Ferle, SRC.SI
42
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ranking in BusinessObjects Reports

Ranking in BusinessObjects Reports

Ranking in BusinessObjects Reports

Maja Ferle, SRC.SI

Page 2: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 3

Topics

Introduction

Simple ranking

Ranking top (n) using variables

Ranking with a database analytical function

Cumulative percentage

Q&A

Page 3: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 4

Introduction

About the speaker Business Intelligence Consultant, SRC.SI, Slovenia 9+ years of BI experience Member of BOB

Business intelligence solutions using BusinessObjects Banking Manufacturing Telecommunications

Different industries but same types of user requirements Most profitable customers (products) Top (n) customers (products) Revenue by cumulative percentage

Page 4: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 5

Topics

Introduction

Simple ranking

Ranking top (n) using variables

Ranking with a database analytical function

Cumulative percentage

Q&A

Page 5: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 6

Simple Ranking 1/5

Modified Island Resorts marketing universe Added more data to the database

Sample report #1 Number of guests by country of resort Display the top 3 countries

Step 1: Create the report Use objects Country and Number of guests

Illustration of simple ranking techniques

Page 6: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 7

Simple Ranking 2/5

Step 2: Apply ranking Ranking is always performed on a dimension based on a measure Use the ranking toolbar button or choose Format Ranking

from the menu Enter Top 3

Based on Number of guests

Page 7: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 8

Simple Ranking 3/5

Result

Step 3: Display the rank order Use the rank() function Add a new column to the table Enter the formula

=Rank(<Country> ,<Number of guests>)

Page 8: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 9

Simple Ranking 4/5

Result

Change the report: Display the top 5 countries Choose Format Ranking from the menu Do not use the ranking toolbar button again because it will undo

the previous ranking settings Enter Top 5 Based on Number of guests

Page 9: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 10

Simple Ranking 5/5

Result

The challenge: Ranking top (n) Users of InfoView do not have the ranking capability End-users may not know how to apply ranking Users want to enter the value of n as a response to a prompt when

refreshing the report

Page 10: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 11

Topics

Introduction

Simple ranking

Ranking top (n) using variables

Ranking with a database analytical function

Cumulative percentage

Q&A

Page 11: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 12

Ranking Top (n) Using Variables 1/10

Two ways of prompting the user for the value of n

First way: In the universe Define an object to hold the prompted value in the universe Use the @Prompt function

to define the object

@Prompt(‘Enter value fortop (n): ‘, ‘n’,,,)

Caution: this objectwill not parse but it willwork correctly whenused in a report

Allow the user to enter the value of n when refreshing a report

Page 12: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 13

Ranking Top (n) Using Variables 2/10

Second way: In the report This is a quick and dirty solution Caution: it may interfere with the database query optimizer

Page 13: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 14

Ranking Top (n) Using Variables 3/10

What to do in the report Convert the prompted value of (n) to a number and assign the value

to the variable Value of n

=ToNumber(UserResponse("Query 1 with bch_demo","Enter value for top (n): "))

Page 14: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 15

Ranking Top (n) Using Variables 4/10

Sample report #2: Display the top (n) countries

Step 1: Create the report Use objects Country and Number of guests For illustration purposes add the Rank column using the rank()

function

Page 15: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 16

Ranking Top (n) Using Variables 5/10

Step 2: Flag the rows that should be displayed Use a variable to flag the rows Create a new column to the right of the table Add the formula and assign it to a variable named Display row flag

=If Rank(<Country>,<Number of guests>)<= <Value of n> Then 1 Else 0

Result

Page 16: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 17

Ranking Top (n) Using Variables 6/10

Step 3: Apply ranking to the Display row flag variable Enter Top 1 Based on Display row flag

Page 17: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 18

Ranking Top (n) Using Variables 7/10

Result

Step 4: Remove unnecessary columns You may delete the Rank column because it was used for illustration

purposes only Do not delete the Display row column because the ranking is based

on this variable You may hide the Display row column

Page 18: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 19

Ranking Top (n) Using Variables 8/10

Hide the Display row flag variable Choose Table Format from the menu In the Pivot tab choose the Display row flag variable and click Hide

Page 19: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 20

Ranking Top (n) Using Variables 9/10

Step 5: Format the title

= "Top " + UserResponse ("Query 1 with bch_demo" , "Enter value for top (n):") + " countries by number of guests"

Result

Change the report: Refresh for a different value of (n)

Page 20: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 21

Ranking Top (n) Using Variables 10/10

Result

Problem with the variable approach The rows are not sorted A sort may not be applied after a ranking Users are not happy with this report

The challenge: Find a better solution

Page 21: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 22

Topics

Introduction

Simple ranking

Ranking top (n) using variables

Ranking with a database analytical function

Cumulative percentage

Q&A

Page 22: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 23

Ranking with a Database Analytical Function 1/9

Database analytical functions Available in Oracle, DB2, and MS SQL Server Sort in descending order if you wish to rank by highest values rank() over(order by <measure> desc)

Example of the RANK() analytical function in Oracle SQLSELECT country, number_of_guests,

rank() over(order by number_of_guests desc) rank_value

FROM guests

COUNTRY NUMBER_OF_GUESTS RANK_VALUE

------------------------------------------------

Belgium 770 1

Greece 757 2

France 746 3

Page 23: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 24

Ranking with a Database Analytical Function 2/9

Create a measure object in the universe

rank() over(order by sum(Invoice_Line.nb_guests) desc)

Add the analytical function to the universe

Page 24: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 25

Ranking with a Database Analytical Function 3/9

Set the default aggregation to none Rank is not additive

Page 25: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 26

Ranking with a Database Analytical Function 4/9

Sample report #3: Display the top (n) countries

Step 1: Create a new report Use objects Country, Number of guests and the new analytical

function object Rank number of guests

Page 26: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 27

Ranking with a Database Analytical Function 5/9

Result

Advantages The database calculates the rank order therefore the rank order is

treated like any other variable in the report Sorts and filters are allowed

Step 2: Add the prompt to retrieve the value of n Possible approach: add a prompt in the query conditions pane

Page 27: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 28

Ranking with a Database Analytical Function 6/9

Prompt at the query level in the conditions pane Drag the object Rank number of guests into the conditions pane Caution: this will produce an error because an analytical function may

not be used in the where clause of an SQL statement

Page 28: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 29

Ranking with a Database Analytical Function 7/9

Prevent the users from producing such errors At the universe level, uncheck the option Can be used in Condition

on the Advanced tab of the Rank number of guests object properties

Page 29: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 30

Ranking with a Database Analytical Function 8/9

Step 2: Add the prompt to retrieve the value of n Better approach: See Sample report #2 for ways to add the prompt

Step 3: Include a custom filter Choose Format Filters from the menu Add the custom filter

= <Rank number of guests> <= <Value of n>

Page 30: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 31

Ranking with a Database Analytical Function 9/9

Result

Advantages of this approach Data may be sorted any way in the table

Disadvantages of this approach All data is retrieved from the database into the report because it is

filtered at the report level which may cause performance issues

Page 31: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 32

Topics

Introduction

Simple ranking

Ranking top (n) using variables

Ranking with a database analytical function

Cumulative percentage

Q&A

Page 32: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 33

Cumulative Percentage 1/9

Sample report #4: Show the countries with the top 80% of guests

Step 1: Create the report Use the objects Country and Number of guests Sort by Number of guests in descending order

Page 33: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 34

Cumulative Percentage 2/9

Step 2: Add a running sum of the number of guests Add a new column to the right of the table Enter the formula for running sum

=RunningSum(<Number of guests>)

Page 34: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 35

Cumulative Percentage 3/9

Step 3: Calculate the cumulative percentage Add one more column to the right of the table Enter the formula

=RunningSum(<Number of guests>) / Sum(<Number of guests>) ForAll <Country>

Page 35: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 36

Cumulative Percentage 4/9

The challenge: Display the countries that contribute 80% of the guests Possible approach: add a custom filter But it does not work: Cannot use aggregates in complex filters

The solution: use a database analytical function to calculate the cumulative percentage

Page 36: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 37

Cumulative Percentage 5/9

Analytical function to calculate cumulative percentageselect country, number_of_guests,(sum(sum(number_of_guests)) over (order by sum(number_of_guests) desc)) / (sum(sum(number_of_guests)) over ()) cum_percent

from guestsgroup by country, number_of_guests

COUNTRY NUMBER_OF_GUESTS CUM_PERCENTBelgium 770 0.33Greece 757 0.66France 746 0.98Slovenia 22 0.99Portugal 21 1

Page 37: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 38

Cumulative Percentage 6/9

Add a new object to the universe(sum(sum(Invoice_Line.nb_guests))

over (order by sum(Invoice_Line.nb_guests) desc)) /(sum(sum(Invoice_Line.nb_guests)) over ())

Page 38: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 39

Cumulative Percentage 7/9

Use the object in the report Include the new object Cum. percentage number of guests in the

report The cumulative percentage is now calculated by the database and is

treated just like any other variable in the report

Page 39: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 40

Cumulative Percentage 8/9

Prompt for the value of x percent Add the prompt to retrieve the value of x Use the same prompting techniques as in previous sample reports Convert the prompted value of x to a variable named Value of x

Custom filter the report for top x percent Add a custom filter to the report

=<Cum. percentage number of guests> <= (<Value of x>/100)

Page 40: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 41

Cumulative Percentage 9/9

Result

Refresh for a different value of x

Page 41: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 42

Topics

Introduction

Simple ranking

Ranking top (n) using variables

Ranking with a database analytical function

Cumulative percentage

Q&A

Page 42: Ranking in BusinessObjects Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 43

Q&A

Sample reports will be made available for download

Contact information Maja Ferle, SRC.SI, Slovenia www.src.si [email protected]