Question

I know the exact SQL I would need to write to retrieve the results I'm looking for from the Oracle BI tool, however, as I am new to Oracle BI I am struggling to find a way to reproduce the same results. I realize that the ultimate answer largely depends on the BI data model and that takes a lot more communication than a question on Stack Overflow will allow, so I'm looking for more generic how-to answers than a specific definitive answer for my scenario.

Perhaps the SQL will help for starters:

select "All"."DT", ("LessThan5Mins"."Count" / "All"."Count") * 100 
from
(
    select to_char(m."EndDateTime", 'YYYY-MM') "DT", count(*) "Count"
    from "Measurement" m,
         "DwellTimeMeasurement" dtm
    where dtm."MeasurementBase_id" = m."Id"
    group by to_char(m."EndDateTime", 'YYYY-MM')
) "All",
(
    select to_char(m."EndDateTime", 'YYYY-MM') "DT", count(*) "Count"
    from "Measurement" m,
         "DwellTimeMeasurement" dtm
    where dtm."MeasurementBase_id" = m."Id"
    and m."MeasValue" <= 300
    group by to_char(m."EndDateTime", 'YYYY-MM')
) "LessThan5Mins"
where "All"."DT" = "LessThan5Mins"."DT";

The purpose of this is to return the percentage of dwell time records that were less than or equal to 5 mins (300 seconds).

I have a fact that represents the "MeasValue" field in the above query.

All attempts I've made to reproduce the dual result set nature of the above query in BI have failed.

Is the above possible in OBIEE and if so, how might I achieve this?

Was it helpful?

Solution

I'm assuming that you have imported the Measurement (M) and DwellTimeMeasurement (DTM) tables into the physical layer of the RPD, specified the join on DTM.MeasurementBase_id = M.Id, and then brought them both through to the presentation layer.

If so, then you could start building this query in Answers on the criteria tab by dragging in M.EndDateTime and any OBIEE measure column from DTM, for example DTM.Amount. Edit the formula for the DTM.Amount column:

Edit column formula

Filter the column by clicking the filter button shown in blue below.

enter image description here

In the following dialog box double click on M.MeasValue and then select "is less than or equal to" and type 300 in the Value text box. Click OK twice and your column formula should now look something like this:

FILTER(DTM.Amount USING (M.MeasValue <= 300))

Now wrap this with COUNT():

COUNT(FILTER(DTM.Amount USING (M.MeasValue <= 300)))

This will give the count of records with M.MeasValue <= 300. You could rename this column to be "LessThan5Mins". Click OK to save the new formula. Now drag in the DTM.Amount column again but this time only perform a COUNT():

COUNT(DTM.Amount)

This will give you the count of all dwell time records. You could rename this to "All". Finally drag in the DTM.Amount column one last time and edit it's formula again. This is where you will calculate the percentage with a formula similar to the following:

COUNT(FILTER(DTM.Amount USING (M.MeasValue <= 300))) / COUNT(DTM.Amount) * 100

So ultimately you will have four columns with the following titles and formulas:

TITLE            FORMULA
-----            --------
EndDateTime      M.EndDateTime
LessThan5Mins    COUNT(FILTER(DTM.Amount USING (M.MeasValue <= 300)))
All              COUNT(DTM.Amount)
% LessThan5Mins  COUNT(FILTER(DTM.Amount USING (M.MeasValue <= 300))) / COUNT(DTM.Amount) * 100

Note that including the EndDateTime column takes care of grouping the records. Also, to match your original query you would only need the EndDateTime and % LessThan5Mins columns (you could hide or exclude the other columns) but I wanted to demonstrate for you the process of filtering column values in OBIEE.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top