BIEE & BI Publisher parameter & dynamic column selection

Hi Gurus!
I want to create a SQL Query on the BIServer from BIPublisher that create a data set that dynamically return a different column based on a BI Publisher parameter (that i will feed from a Dashboard prompt);
I've tried to write something like the follow query, but always it returns errors...
select case when :Parameter='Measure1' then mytable.measure1 else mytable.measure2 end as Measure, mytable.dim1 as Dim from mytable where mytable.year=:YearParam;
the parameter in the where works, but I'm not able to use the parameter in the case clause.
Is it possible to use the parameter in the case statement?
If i write a similar sql against a RDBMS it works great..
I'n on a 10.1.3.4.1
Any suggestion?
Regards,
Daniele

You might use the indexcol function for this purpose.
http://download.oracle.com/docs/cd/E12096_01/books/admintool/admintool_SQL15.html
In the document, you have a hierarchy example.
Success
Nico

Similar Messages

  • How to create a dynamic RTF report which creates dynamic columns based on dynamic column selection from a table?

    Hi All,
    Suppose I have table, whose structure changes frequently on daily basis.
    For eg. desc my_table gives you following column name on Day 1
    SQL > desc my_table;
    Output
    Name
    Age
    Phone
    On Day 2, two more columns are added, viz, Address and Salary.
    SQL > desc my_table;
    Output
    Name
    Age
    Phone
    Address
    Salary
    Now I want to create an Dynnamic RTF report which would fetch data from ALL columns from my_table on daily basis. For that I have defined a concurrent program with XML as output type and have attached a data template/data definition to it which takes in XML as input and gives final output of conc program in EXCEL layout. I am able to do this for constant number of columns, but dont know how to do it when the number of columns to be displayed changes dynamically.
    For Day 1 my XML file should be like this.
    <?xml version="1.0" encoding="UTF-8"?>
    <dataTemplate name="XYZ" description="iExpenses Report" Version="1.0">
    <dataQuery>
    <sqlStatement name="Q2">
    <![CDATA[
    SELECT Name
    ,Age
    ,Phone
    FROM my_table
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_my_table" source="Q2">
      <element name="Name" value="Name" />
      <element name="Age" value="Age" />
      <element name="Phone" value="Phone" />
    </group>
    </dataStructure>
    </dataTemplate>
    And my Day 1, EXCEL output from RTF template should be like this.
    Name     Age     Phone
    Swapnill     23     12345
    For Day 2 my XML file should be like this. With 2 new columns selected in SELECT clause.
    <?xml version="1.0" encoding="UTF-8"?>
    <dataTemplate name="XYZ" description="iExpenses Report" Version="1.0">
    <dataQuery>
    <sqlStatement name="Q2">
    <![CDATA[
    SELECT Name
    ,Age
    ,Phone
    ,Address
    ,Salary
    FROM my_table
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_my_table" source="Q2">
      <element name="Name" value="Name" />
      <element name="Age" value="Age" />
      <element name="Phone" value="Phone" />
      <element name="Address" value="Address" />
      <element name="Salary" value="Salary" />
    </group>
    </dataStructure>
    </dataTemplate>
    And my Day 2, EXCEL output from RTF template should be like this.
    Name     Age     Phone     Address     Salary
    Swapnill     23     12345         Madrid     100000
    Now, I dont know below things.
    Make the XML dynamic as in on Day 1 there must be 3 columns in the SELECT statement and on Day 2, 5 columns. I want to create one dynamic XML which should not be required to be changed if new columns are added in my_table. I dont know how to create this query and also create their corresponding elements below.
    Make the RTF template dyanamic as in Day1 there must 3 columns in EXCEL output and on Day 2, 5 columns. I want to create a Dynamic RTF template which would show all the columns selected in Dynamic XML.I dont know how the RTF will create new XML tags and how it will know where to place it in the report. Means, I can create RTF template on Day 1, by loading XML data for 3 columns and placing 3 XML tags in template. But how will it create and place tags for new columns on Day 2?
    Hope, you got my requirement, its a challenging one. Please let me know how I can implement the required solution using RTF dynamically without any manual intervention.
    Regards,
    Swapnil K.
    Message was edited by: SwapnilK

    Hi All,
    I am able to fulfil above requirement. Now I am stuck at below point. Need your help!
    Is there any way to UPDATE the XML file attached to a Data Definition (XML Publisher > Data Definition) using a standard package or procedure call or may be an API from backend? I am creating an XML dynamically and I want to attach it to its Data Definition programmatically using SQL.
    Please let me know if there is any oracle functionality to do this.
    If not, please let me know the standard directories on application/database server where the XML files attached to Data Definitions are stored.
    For eg, /$APPL_TOP/ar/1.0/sql or something.
    Regards,
    Swapnil K.

  • Dynamic column selection

    I want to select specific columns from a table dynamically which are basically the columns returned by quering the user_tab_columns data dictionary which in turn has to satisfy certain condition for me.
    So, what I want to do is something like:
    SELECT b.(dynamic column list from a)
    FROM b,
    (SELECT column_name FROM user_tab_columns WHERE table_name='STH' AND ........) a
    any help will be greatly appreciated.

    sql>create or replace procedure p_dynamic_sql
      2  is
      3    v_sql varchar2(4000);
      4  begin
      5    v_sql := 'select ';
      6    for r in (select column_name
      7                from user_tab_cols
      8               where table_name = 'EMP'
      9                 and column_name like 'E%') loop
    10      v_sql := v_sql || r.column_name || ',';
    11    end loop;
    12    v_sql := rtrim(v_sql, ',') || ' from emp';
    13    dbms_output.put_line( v_sql );
    14    -- do something with SQL (open cursor, etc.)   
    15  end;
    16  /
    Procedure created.
    sql>exec p_dynamic_sql
    select EMPNO,ENAME from emp
    PL/SQL procedure successfully completed.

  • Dynamic column selection while running report

    Can any one explain how to get the following functionality in report:
    I have a cube with following fields:(with depriciaated amounts)
    Plant  Mat#  Fiscper       Jan   Feb  March April  May   June   July   Aug   Sep   Oct   Nov   Dec
    ==== ====    =====      ==== ==== ===== ==== ==== ===== ==== ==== ===== ==== ==== ====
    P1      M1     03/2009    $100    $90   $80   
    P1      M1     04/2009    $100    $90   $80     $70  
    P2      M2     04/2009     $10     $9      $8     
    P2      M2     04/2009     $10     $9      $8      $7
    When I run the report with Fiscper as selection, ie 04/2009, I shoud get the report displayed only April column
    Report out put: (Only April column should be displayed)
    Plant  Mat#  Fiscper       April
    ==== ====    =====       ====
    P1      M1     04/2009    $70      
    P2      M2     04/2009     $7
    When I run the report with Fiscper as selection, ie 03/2009, I shoud get the report displayed only March column
    Report out put: (Only March column should be displayed)
    Plant  Mat#  Fiscper       March
    ==== ====    =====       ====
    P1      M1     04/2009    $80      
    P2      M2     04/2009     $8
    Can any explain how to desing this in query designer?
    Thanks,
    PV

    create new selection
    drag and drop the kf
    drag and drop calmonth
    create formula variable for calmonth using type as "customer exit"
    now based on the fiscperiod you can fill calmonth in customer exit which will give you desired output
    you can use text variable if you want the heading for the KF to be dynamic.

  • Matrix report in XML publisher with dynamic column groups

    hi,
    i have one matrix report in txt format having 5 columns under 1 month heading.
    Now i want that all these 5 columns should repeat for multiple months depending upon input parameters.
    S. No.
    Organization Name
    Organization Id
    Project Code
    1
    GRANDWOODS 2
    6825
    1495
    month
    January
    Wrk Count Ven
    Wrk Cont Prw New
    Wrk Amt Ven New
    Wrk Amt Prw New
    Tot Amt New
    New
    0
    0
    0
    0
    0
    Existing
    0
    1
    0
    255000
    255000
    Total
    0
    1
    0
    255000
    255000
    rtf template is as follows:
    S. No.
    Organization Name
    Organization Id
    Project Code
    F CS_11
    ORGANIZATION_NAME
    ORGANIZATION_ID
    PROJECT_CODE E
    month
    Wrk Count Ven
    Wrk Cont Prw New
    Wrk Amt Ven New
    Wrk Amt Prw New
    Tot Amt New
    New
    F WRK_COUNT_VEN_NEW
    WRK_CONT_PRW_NEW
    WRK_AMT_VEN_NEW
    WRK_AMT_PRW_NEW
    TOT_AMT_NEW
    Existing
    F WRK_CONT_VEN_EXISTING
    WRK_CONT_PRW_EXISING
    WRK_AMT_VEN_EXISTING
    WRK_AMT_PRW_EXISTING E
    TOT_AMT_EXIS
    Total
    TOT_CONT_VEN_NEW_EXIS
    TOT_CONT_PRW_NEW_EXIS
    TOT_AMT_VEN_NEW_EXIS
    TOT_AMT_PRW_NEW_EXIS
    TOT E
    E
    now, please help me as to how repeat these 5 columns for multiple months.
    if anybody has some template for matrix report with multiple coloumn group repeatation, pls. share along with sample data.
    regards,
    mohit gupta

    Hi,
    Check this link for developing the matrix report
    Oracle Database and Oracle Applications: Matrix Report in XML Publisher
    Regards
    Srikkanth

  • Dynamic column selection based on login in BI Answers

    Hi
    I have a dimension with manager level 1 to 10, based on the user login, I want to display the table with the column (level 1 or level n) dynamically ( ex: if the user is in manager level n, display column level n with other data in the table). P.S. there are more than 10000+ users, so I can't customize each user.
    can you please let me know if this is possible and how to do it?
    Thanks a lot,

    You might use the indexcol function for this purpose.
    http://download.oracle.com/docs/cd/E12096_01/books/admintool/admintool_SQL15.html
    In the document, you have a hierarchy example.
    Success
    Nico

  • How can we get Dynamic columns and data with RTF Templates in BI Publisher

    How can we get Dynamic columns and data with RTf Templates.
    My requirement is :
    create table xxinv_item_pei_taginfo(item_id number,
    Organization_id number,
    item varchar2(4000),
    record_type varchar2(4000),
    record_value CLOB,
    State varchar2(4000));
    insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'USES','fever','TX');
    insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'HOW TO USE','one tablet daily','TX');
    insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'SIDE EFFECTS','XYZ','TX');
    insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'DRUG INTERACTION','ABC','TX');
    insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'OVERDOSE','Go and see doctor','TX');
    insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'NOTES','Take after meal','TX');
    select * from xxinv_item_pei_taginfo;
    Item id Org Id Item Record_type Record_value State
    493991     224     1265-D30     USES     fever     TX
    493991     224     1265-D30     HOW TO USE     one tablet daily     TX
    493991     224     1265-D30     SIDE EFFECTS     XYZ     TX
    493991     224     1265-D30     DRUG INTERACTION     ABC     TX
    493991     224     1265-D30     OVERDOSE      Go and see doctor     TX
    493991     224     1265-D30     NOTES     Take after meal     TX
    Above is my data
    I have to fetch the record_type from a lookup where I can have any of the record type, sometime USES, HOW TO USE, SIDE EFFECTS and sometimes some other set of record types
    In my report I have to get these record typpes as field name dynamically whichever is available in that lookup and record values against them.
    its a BI Publisher report.
    please suggest

    if you have data in db then you can create xml with needed structure
    and so you can create bip report
    do you have errors or .... ?

  • Cannot use alias for dynamic column name in SELECT statement

    Hi,
    I want to retrieve values from several tables by using dynamic column & table name as below:
    DATA: tbl_name(30) TYPE c VALUE '/bic/tbi_srcsys',  " staticly initialized for this example
               col_name(30) TYPE c VALUE '/bic/bi_srcsys'.  " staticly initialized for this example
    SELECT (col_name) INTO CORRESPONDING FIELDS OF TABLE it_values FROM (tbl_name).
    The internal table "it_values" does not contain a field named "/bic/bi_srcsys", instead it has another generic field "value" so that the above code can be applied to other tables. I tried to use alias (AS) as below:
    SELECT (col_name) AS value INTO CORRESPONDING FIELDS OF TABLE it_values FROM (tbl_name).
    But this cannot work. I know that there are other ways to solve this problem, such as by using a single field in SELECT .. ENDSELECT and subsequently appending it to the work area and internal table as below:
    SELECT (col_name)  INTO (lv_value) FROM (tbl_name).
      wa_value-value = lv_value.
      APPEND wa_value TO it_values.
    ENDSELECT.
    Just wonder if there is any other more elegant workaround, because I might have several other fields instead of only one?
    Thanks.
    Regards,
    Joon Meng

    Hi Suhas,
    thanks for the quick reply.
    Sorry that I have not well described the structure of the internal table "it_values". This internal table contains several other fields (key, type, value, etc.).
    I guess that the following code
    SELECT (col_name) INTO TABLE it_values FROM (tbl_name).
    works if the internal table only has one field (value) or the field "value" is in the first position, right?
    In this case, I need to fill the "value" field of internal table it_values (ignore the other fields like type, key) with values retrieved from (col_name) of the DDIC table.
    Looking forward to your reply.
    BR,
    Joon Meng

  • Creating Dynamic Column Names at Runtime

    I have a dynamic query that I'm running under Portal. I would
    like to assign column headings based on the query results.
    Example:
    Select a.x "a.name_x",
    a.y "a.name_y",
    a.z "a.name_z"
    from a
    where a.q = "user input"
    I know the above example will not run, but I'm using it to make
    the point as to what I would like display as column headings.
    TIA
    Sean

    Hi,
    You can try this
    select 'col_name1' col1, 'col_name2' col2, ..., 'col_namen' coln
    from dual
    union all
    select col1, col2, ... coln from tbl
    then, eg. you're building a report, you can just set each column
    heading text to ' '. of course you can use such as
    select decode(:var,1,'col_name1',2,'col_name2...)...
    This trick is not suitable for multi-page report publishing, cos
    the column headings are actually the first line of record.
    hope that would help
    JC

  • Saving result from sp_executesql into a variable and using dynamic column name - getting error "Error converting data type varchar to numeric"

    Im getting an error when running a procedure that includes this code.
    I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
    DECLARE @retval AS DECIMAL(12,2)
    DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
    DECLARE @sqlcmd AS NVARCHAR(150)
    DECLARE @paramdef NVARCHAR(150)
    SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
    SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
    SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
    SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
    --default
    SET @retval = 0.0;
    EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
    SELECT @retval
    DECLARE @return_value DECIMAL(12,2)
    EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
    @SpreadKey = 1,
    @MonthNumber = 4
    SELECT 'Return Value' = @return_value
    Msg 8114, Level 16, State 5, Line 1
    Error converting data type varchar to numeric.

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
    This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
    the shoe size, the phone number or something else at run time of this entity. 
    In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point. 
    Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity. 
    Do you know that SQL is a declarative language? This family of languages does not use local variables! 
    Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.  
    Think about how silly this is: 
     SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
    We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental. 
    We need to see the DDL so we can re-write this mess. Want to fix it or not?
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Dynamic Column Selector in OBIEE - Solution required

    Hello Experts,
    I am pretty new to OBIEE. Please help me to get OBIEE solution for below requirement.
    I have one 25 column dimension table in database. Created OBIEE .rpd file and published in BI server. Now I need to provide one user interface in which user should be able to chose any number of columns of his choice and he should get record set of those selected columns. Something in my mind is like this.
    I should be providing list of 25 column names with check box to select one or many. Assuming that if user selects Col1, Col3,Col5 and Col7 then he should get the result in excel file with record set of those 4 columns.
    I am using OBIEE 10g.
    Any solution for this is highly appreciated.
    Edited by: user7850154 on Dec 5, 2010 9:22 AM

    user,
    Usually, dynamic column seletor is implemented through "column selector view" available within compund layout of OBIEE Answers.
    But, it does allow you to select only single column rather than multiple columns - which in your case is required.
    J
    -bifacts
    http://www.obinotes.com

  • Difficult to achive the report layout with dynamic column names

    I have a report layout as below.
    So here the column names are dynamic.And each fixed row group has different calculations. I have a date parameter. If I select July 2013, then I need to show data from July 2012 to July 2013 with Columns(Jul-12, Aug-12...Jul-13). How to achive below layout
    with dynamic columns?

    Hi Sarayu_CM,
    According to your description, you want to filter the records of prior year based on only one parameter selection. Right?
    In this scenario, we can create two parameters. The first one is for user to select. The second parameter is based on the first parameter selection. We don't need to specify Available Values for the second parameter, but we should use expression to specify
    Default Values based on the first parameter selection. Use the expression below:
    =DateAdd("m",-12,FormatDateTime(Parameters!param1.Value))
    Then we just need to apply a filter on the matrix/dataset to get the records which the date is between values in these two parameters.
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Dynamic Columns in SSRS

    Hello,
     I am using sql 2012 SSRS.
    My requirement  :
    I have Database which has got 100 tables.I need to create SSRS report which display top 10 records from the table within that database.
    User will select The table name as parameter in the report. the number of column in each table will vary .
    kindly shed some light on above problem.
    I am using the below statement in stored proc, and calling same from ssrs report
    exec(
    'select top 10 * from ['+@datbasename+'] .[app].'+@tablename+'')
    Regards
    Prasanna KJ
    Praxy

    Hi Prasanna,
    Just as Visakh mentioned, we can’t get the report to display dynamic columns in a report based on the different table names. So for your requirement, it can’t be achieved currently.
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • How to change recordset bahaviour to accept dynamic column names in the where clause

    Hi
    im using php-mysql and i make a recordset and i want to make the column names in the where clause to be dynamic like
    "select id,name from mytable where $tablename-$myvar";
    but when i do this my i break the recordset and it disappear
    and when i use variables from advanced recordset it only dynamic for the value of the column not for the column name
    and when i write the column name to dynamic as above by hand it truns a red exclamation mark on the server behaviour panel
    so i think the only way is to change the recordset behaviour is it? if so How to make it accept dynamic column names?
    thanks in advance.

    As bregent has already explained to you, customizing the recordset code will result in Dreamweaver no longer recognizing the server behavior. This isn't a problem, but it does mean that you need to lay out your dynamic text with the Bindings panel before making any changes. Once you have changed the recordset code, the Bindings panel will no longer recognize the recordset fields.
    Using a variable to choose a column name is quite simple, but you need to take some security measures to ensure that the value passed through the query string isn't attempting SQL injection. An effective way of doing this is to create an array of acceptable column names, and check that the value matches.
    // create array of acceptable values
    $valid = array('column_name1', 'column_name2', 'column_name3');
    // if the query string contains an acceptable column name, use it
    if (isset($_GET['colname']) && in_array($_GET['colname'], $valid)) {
      $col = $GET['colname'];
    } else {
      // set a default value if the submitted one was invalid
      $col = 'column_name1'
    You can then use $col directly in the SQL query.

  • Based on the input parameter can OBIEE select table at run time

    For e.g if we select monthly from the drop down then the same report must fetch data from monthly report
    and at the same time if a persons selects daily then the same reprot must fetch data from daily table.

    Let's assign a presentation variable to the drop down values i.e. var_Status
    Now in functionality of the column that you want to change it's functionality dynamically depends on your selection... write this formula
    case when '@{var_Status}' = 'Daily' then Table1.Col1 else Table2.col2 end
    Because of this.. we can't have dynamic column heading for this column.
    One more approach is: Same Presentation variable but with Sectional Guided navigation properties.
    see here: http://oraclebizint.wordpress.com/2008/01/17/oracle-bi-101332-selecting-reports-from-dashboard-prompts-and-guided-navigation-sections/
    You have to develop 2 reports for this..
    Regards
    Kishore Guggilla

Maybe you are looking for

  • HDMI output not working on my Satellite L500

    The HDMI output on my Satellite L500 seems to have stopped working in the past few months. I've tried different cables but it is still not working. Any ideas?

  • In  RSA1 transaction, I written SELECT QUERY while compile It shows error

    Hi All,                While compile my SELECT query in RSA1 trans, ENDROUTINE, It show error...             Select single MAX( date )                      from dbtable                      into W_DATE                     where DOC_NUMBER = w_itab-DO

  • HR Table fields required

    Hi Everybody,   Could anybody help me in resolving my problem? I need SAP-HR TCodes, where can I get these fields details for example, Ed Level, EEO Ethnic Code, No. of dependants etc. for Personal data for New Hires/EE Changes? Similarly, I need mor

  • How to Swing in Java?

    Hi folks, I'm trying to write very basic GUI, but have just realized that I do not have swing library. When tried to download it from web various sources were saying that it has been discontinued (Life of Product Ended). Could anyone tell from were a

  • Can't delete sparsebundle and can't reformat TC

    i am backing up my MBP to a Time Capsule (via WiFi) connected to my Mac Pro and i want to reformat the drive and start over. basically i have one sparsebundle from the mac pro on it and one sparsebundle from the MBP and i cannot for the life of me fi