Oracle Analytics Cloud and Server

Welcome to the Oracle Analytics Community: Please complete your User Profile and upload your Profile Picture

OBIEE multiple row values in one row

Received Response
485
Views
7
Comments
KashSidd
KashSidd Rank 5 - Community Champion

I am trying to find out a solution where I can get the next three values of a column and add them in another field within the same row. So I found the LISTAGG function but its not working for me. Here is the function that I am using:

CAST(EVALUATE_AGGR('LISTAGG(%1,%2) WITHIN GROUP (ORDER BY %3 DESC)',"Measures"."Strm",', ',) as char(16))

This is what I get:

pastedImage_8.png

I dont know how I would be able to get the next three "STRM" values to show up as follows:

pastedImage_9.png

BTW, the "Strm" will be entered through a report prompt so lets say if the User inputs "2336" then I will be needing the next two terms which in this case will be 2354 and 2366. I was thinking to use Presentation variables to pass the prompt values to the report.

Answers

  • Christian Berg-0racle
    Christian Berg-0racle Rank 10 - Analytics Guru

    You want the values from different rows to become distinct columns?

    Well the most intelligent solution is to ETL this data into the correct form because otherwise this will be a very heavy operation that gets executed all the time.

  • KashSidd
    KashSidd Rank 5 - Community Champion

    The values are from the same column and this is how it looks in a table:

    pastedImage_0.png

  • Srinivas Malyala-Oracle
    Srinivas Malyala-Oracle Rank 4 - Community Specialist

    May be try this. First get a unique rank by row_number db function then do a pivot view.  I have used different sample set Start Day Name (in your case emplid) ,Start Date (Strm)

    In pivot view pull Strm as measure and set aggregation rule as Min (or Max).

    pastedImage_1.png

  • KashSidd
    KashSidd Rank 5 - Community Champion

    Thank you and it works

    It looks like:

    pastedImage_2.png

    Last thing I was looking for is to get the First 3 STRM's and also have to remove Nulls. I was trying out the LISTAGG but it doesnt work well with ROW_NUMBER already there... Please let me know should you have some solution?

  • Srinivas Malyala-Oracle
    Srinivas Malyala-Oracle Rank 4 - Community Specialist

    If you are looking for only 3 then you need to filter on column which has row number (row_number <=3)

  • KashSidd
    KashSidd Rank 5 - Community Champion

    I tried but it doesnt work and here is the filter:

    pastedImage_0.png

    I get the following error:

    ORA-30483: window functions are not allowed here at OCI call OCIStmtExecute. (HY000)

  • Christian Berg-0racle
    Christian Berg-0racle Rank 10 - Analytics Guru

    Basically why I didn't participate in the thread anymore and will just re-iterate my statement: this best goes into the physical design.