Displaying counts of records, each meeting different crite

Hello all,

I have to replicate a report that displays the number of records, each meeting a different criteria, all within one report. Each column essentially needs to have its own where clause (ex. count(invoice_no) wheretrans_date is 1-15 days old, count(invoice_no) where trans_date is 16-30 days old, etc, etc). If I use individual objects at the universe level with different where clauses on each, no data is returned. If I call a database function (passing it parameters from individual universe objects) to perform the counts, I lose the required flexability for the users in limiting their reports.

An example of the columns to be displayed are:
Site
Market
District
Product
Market Location
NTI

between >15 days old

between 16-30 days old

between 31-45 days old

between 46-60 days old

between 61-90 days old

between 91-120 days old

between 121-180 days old

between <180 days old

We are using Oracle 8.1.5, Business Objects 5.0 and Web Intelligence 2.5 on a windows NT server. Any suggestions or ideas??

Thanks for any help.

-Dennis


Listserv Archives (BOB member since 2002-06-25)

Hi Dennis,
Are you using multiple queries (is that what you mean by different where clauses)?
Alternatively can you create a view on your database for this data? Simon


Listserv Archives (BOB member since 2002-06-25)

If I use individual objects at the universe level with
different where clauses on each, no data is returned. If I call a database
function (passing it parameters from individual universe objects) to perform the counts, I lose the required flexability for the users in limiting their reports.

I try not to use the where clause on universe object defintions for this reason. Instead I use a decode statement so that any number of objects can be returned without worrying about the where clauses. Unfortunately decode is not very good at between statements and is only really able to cope with equality - similar in fact to the where clause in Business Objects full client function generator.

A solution would be to use a variable at the report level with an if-then-else statement which would return values 1 thru 8 based upon the categories mentioned above, i.e. Category = If ( <= 15) Then 1 Else If ( > 16 and <=30) Then 2 Else… Once done, create another variable using a count() function with the where operator on the variable you created previously to only count the 1s, i.e. Count() Where (Category=1). Then create another for the 2s and so on.

An alterntive would be to provide this functionality at the database/universe level using firstly a stored procedure to provide the categorisation, then a series of objects using decode statements to perform the count.

For example, here is a stored procedure that I created for a similar purpose:

FUNCTION SF_CATEGORISE (VAL IN NUMBER) RETURN VARCHAR2 IS

V_RET VARCHAR2(15);

BEGIN

IF NVL(VAL, 0) = 0 THEN V_RET := ‘1’;
ELSIF VAL BETWEEN 1 AND 100 THEN V_RET := ‘2’;
ELSIF VAL BETWEEN 101 AND 250 THEN V_RET := ‘3’;
ELSIF VAL BETWEEN 251 AND 500 THEN V_RET := ‘4’;
ELSIF VAL BETWEEN 501 AND 1000 THEN V_RET := ‘5’; ELSIF VAL BETWEEN 1001 AND 2500 THEN V_RET := ‘6’; ELSIF VAL BETWEEN 2501 AND 5000 THEN V_RET := ‘7’; ELSIF VAL BETWEEN 5001 AND 10000 THEN V_RET := ‘8’; ELSIF VAL > 10000 THEN V_RET := ‘9’;
END IF;

RETURN V_RET;

EXCEPTION

WHEN OTHERS THEN

Null;

END;
()

Then create an object at the universe level, say called ‘Count_1’ with the following select statement:

SUM(DECODE(sf_categorise(), 1, 1, 0))

Then another object, say ‘Count_2’ like the following

SUM(DECODE(sf_categorise(), 2, 1, 0))

and so on…

Does this help?

Brian Patterson


Listserv Archives (BOB member since 2002-06-25)

One more idea: why not use a table in the database which holds the group values and then use a between join to the original tables:

table day_group (
group_value varchar(10),
low number,
high number)

then joint this new dimension table to your “fact_table” using:
trunc(sysdate)-trunc(fact_table.trans_date) /* gives the age in days / between date_group.min and date_group.max / joins the corresponding group_value */

date_group should hold the values:
“<15”, 0, 15
“16-30”, 16, 30

note: the 0 in the first row is low enough, because the “age” must be >=0. If age < 0 is possible (trans_date in the future) then use an outer join below.

then add the object “day_group=day_group.group_value” to our universe and to the query and you can create a report based on day_group values…

hope this helps.
Walter

Dennis Elenich schrieb:

Hello all,

I have to replicate a report that displays the number of records, each meeting a different criteria, all within one report. Each column essentially needs to have its own where clause (ex. count(invoice_no) where trans_date is 1-15 days old, count(invoice_no) where trans_date is 16-30 days old, etc, etc). If I use individual objects at the universe level with different where clauses on each, no data is returned. If I call a database function (passing it parameters from individual universe objects) to perform the counts, I lose the required flexability for the users in limiting their reports.

An example of the columns to be displayed are:
Site
Market
District
Product
Market Location
NTI

between >15 days old

between 16-30 days old

between 31-45 days old

between 46-60 days old

between 61-90 days old

between 91-120 days old

between 121-180 days old

between <180 days old

We are using Oracle 8.1.5, Business Objects 5.0 and Web Intelligence 2.5 on a windows NT server. Any suggestions or ideas??


Walter Muellner
Delphi Software GmbH / Austria
w.muellner@delphi.at, Tel. +43-1-8151456, http://www.delphi.at


Listserv Archives (BOB member since 2002-06-25)