3 Replies Latest reply: Nov 28, 2013 8:57 AM by Alex H.

# Filter value based on Date in OBIEE 11g, Reporting Issue

Hi,

I have following tables
Dim_Item
Dim_Loc

Reason Code is the code which discribes the reson behind price change

Amount- price of Item at particular location (Note: one item can have different price at different location)

Load Date - When ever there is price change for a particular item at particular location new record is inserted in the fact load date represents the date on which the data is updated

Item_key  Loc_key  Date_key  Reason_Code  Amount  Load_Date
1                  1        20131113                  0          1400    13/11/2013
1                  1        20131115                  6          1100    15/11/2013
2                  1        20131112                  0          900      12/11/2013
2                  2        20131112                  0          1200    12/11/2013
2                  2        20131113                  3          325      13/11/2013

My report requirement is
Report should show only the Item & location for which there is price change

Report should be like

Item Loc Orignal_Amt Changed_Amt
1       1         1400           1100
2       2         1200            325

I have tried to calculate Orignal_Amt by taking Min(Load_Date) & Changed_Amt by taking Max(Load_Date) but result is not correct
I need to min(Load_Date) or max(load_date) for an Item at particular location
i.e it should be like min(load_date by item_key,loc_key)

then I can filter out Amount based on this min & max value.

How can I achive this, is there any other approach to achive this

Thanks

Sameer

• ###### 1. Re: Filter value based on Date in OBIEE 11g, Reporting Issue

Hello,

Sort the report based on the date key,item key and loc key then apply the filter by top 2 then only the changed records will be available on the report.

thanks,

prassu

• ###### 2. Re: Filter value based on Date in OBIEE 11g, Reporting Issue

Try to create these measures:

"min_amount" = MIN(amount)

"Orignal_Amt" = AGGREGATE(min_amount AT item_key,loc_key)

"max_amount" = MAX(amount)

"Orignal_Amt" = AGGREGATE(max_amount AT item_key,loc_key)

Also create a COUNT() base on item_key,loc_key and filter it by > 1

• ###### 3. Re: Filter value based on Date in OBIEE 11g, Reporting Issue

Hi,

Does this approach with comparing prices in the first and last date of the period actually indicates the price change?

What about the sample data below - is considered to be a price change or not?

Item_key  Loc_key  Date_key  Reason_Code  Amount  Load_Date

2                  2        20131110                  0          325     12/11/2013

2                  2        20131111                  0          1100    12/11/2013

2                  2        20131112                  0          1200    12/11/2013

2                  2        20131113                  3          325      13/11/2013

Option #1:

Use 2 requests:

Req1 selects surrogate key for the first and last record by load date for each location and product. Surrogate key is just a concatenated expression of Item_Key, Loc_Key and Load_Date fields (use separators between them).

For this request you need to filter out all other dates but first and last - use Rank function with BY clause. It will be 2 calculated fields: RANK(Date_Load BY Item_Key, Loc_Key) = last date, RANK(-Date_Load BY Item_Key, Loc_Key) = first date. Select records having any of these ranks=1.

In result this request should return up to 2 records for each product-location combination with surrogate key, something like this for my example:

Item_key  Loc_key  Date_key  Reason_Code  Amount  Load_Date          KEY

2                  2        20131110                  0          325     12/11/2013      LOC:2;ITM:2;DT:20131110

2                  2        20131113                  3          325      13/11/2013     LOC:2;ITM:2;DT:20131113

In fact, it could be more than 2 records in case there are more than 1 change in a day for the price and no time stored on date field. This is up to you how to eliminate duplicates.

Now you have another request, resulting one, which is filtered by Req1 using the same surrogate key expression. Orignal_Amt =Min(Amount), Change_Amt = Max(Amount). Apply a filter to find records with different values between them.

In result, if product price is the same in the beginning and end of period (or it is single record) - these records will be filtered out, otherwise you get them in the report.

Option #2:

Play around with logical SQL under Advanced tab, it allows you to write requests with joins (as regular SQL does).

This is sort of desperate option as such an analysis is hard to maintain (make modifications to it).