Using sql in the filter expression

For a project I need to use a filter which is a construction
with BETWEEN dateFrom AND dateTo.
But the user does not choose these datevalues,
he chooses timePeriods which have a unique startDate.
The dashboard prompts are populated with these timePeriods and the user chooses 2 of these and 2
presentation variables are set.
Now I need to retrieve the according startDate for a chosen timePeriod.
I tried to do this using a sub-query in the filter expression,
but this seems not to be valid in Answers.
In standard SQL it is expressed like this:
select table1.* from table1
where table1.dateValue  BETWEEN
+(select table2.startDate from table2 where table2.timePeriod = 'theChosenValue1')+
AND
+(select table2.startDate from table2 where table2.timePeriod = 'theChosenValue2')+
The return of the subqueries are single row, as it should in such constructions.
I want the where clause to be in the filter expression for the dateValue column in Answers.(trimming of the WHERE keyword)
Is there any other construction that does this trick in the BI Answers/Dashboard environment to do this?
Kind regards

Hi Micek,
Thanks for your quick reaction.
Yes you are right the ChosenValues will be replaced by presentation-variables in the final dashboard,
I just am testing it with constant values in the Answers module.
The problem seems to be that it is not allowed to use a sub-query in the filter expression.
The Answers web application says there is a syntax problem near <select>, while I expect the SQL to be valid.
I guess not all regular SQL is allowed in filter expressions.
And since the report does not try to fetch data, no log of a generated, real SQL is written to the logfile.
I need some alternative for the subquery, but one that is allowed in the filter expression.
The problem is based on the fact that the user chooses a different value then the one that is filtered on.
The timePeriods represent just one startDate, but I cannot use timePeriod itself to filter on.
Because I need a between value, wich does not make sense for a timePeriod element
such as '01-08' or 'JAN-08'.
Several timePeriod notations are used, so using SubString and || to calculate a numeric value from the timePeriod varchar2 is not a good option.
The error says:      
Error getting drill information: SELECT "....
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <SELECT>: Syntax error [nQSError: 26012] . (HY000)
Any input is welcome
kind regards

Similar Messages

  • How to use the prompted value in the filter expression

    Hi
    Is it possible to use the prompted value in the filter expression?
    My requirement is that user will be prompted for a date field and I need to filter the records such that the records are displayed for the last 5 weeks from the date entered by the user.
    If somehow I know how to use the prompted value in the filter expression then this requirement is easy to be done. If this is possible, please guide me?
    If there are other ways to acheive the desired results then please suggest.
    Thanks
    -Jaz

    Edit: example added
    SQL> create table tb_test
      2  ( id number(5)
      3  , tot number(5)
      4  , mon_tot number generated always as (tot*15) virtual
      5  );
    Table created.
    SQL> insert into tb_test (id, tot) values (1, 5);
    1 row created.
    SQL> select * from tb_test;
            ID        TOT    MON_TOT
             1          5         75
    1 row selected.
    SQL> update tb_test
      2  set    tot = 15
      3  where  id = 1;
    1 row updated.
    SQL> select * from tb_test;
            ID        TOT    MON_TOT
             1         15        225
    1 row selected.

  • SQL in reports filter expression

    Hi All,
    I want to filter the report using the 'in' operator and specify a SQL as the expression. I want apex to be use the result of the query as the list of values for the 'in' operator. Is this supported?
    for example can I specify the filter as 'user_name in (select name from user_name_tab where group_id = 10)'
    Thanks
    Edited by: vmedi on Jan 3, 2012 2:53 PM
    Edited by: vmedi on Jan 3, 2012 2:53 PM

    Hi Micek,
    Thanks for your quick reaction.
    Yes you are right the ChosenValues will be replaced by presentation-variables in the final dashboard,
    I just am testing it with constant values in the Answers module.
    The problem seems to be that it is not allowed to use a sub-query in the filter expression.
    The Answers web application says there is a syntax problem near <select>, while I expect the SQL to be valid.
    I guess not all regular SQL is allowed in filter expressions.
    And since the report does not try to fetch data, no log of a generated, real SQL is written to the logfile.
    I need some alternative for the subquery, but one that is allowed in the filter expression.
    The problem is based on the fact that the user chooses a different value then the one that is filtered on.
    The timePeriods represent just one startDate, but I cannot use timePeriod itself to filter on.
    Because I need a between value, wich does not make sense for a timePeriod element
    such as '01-08' or 'JAN-08'.
    Several timePeriod notations are used, so using SubString and || to calculate a numeric value from the timePeriod varchar2 is not a good option.
    The error says:      
    Error getting drill information: SELECT "....
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <SELECT>: Syntax error [nQSError: 26012] . (HY000)
    Any input is welcome
    kind regards

  • The filter expression is on external data and could not be validated.

    The filter expression is on external data and could not be validated. It may not be supported in Web browser forms.
    I am reciveing this error in my infopath 2010 browser form when I am trying to filter a drop down list from sharepoint.
    I thought filters were available on infopath 2010 browser forms or are they only available from values inside the form?
    I did have a look around the forums but only could find this error occuring during beta stage.
    Thanks

    Ok, so you shouldn't be filtering in the form, because that means it downloads the entire list first and then filters out the items.  That's client-side filtering.  What you want to do is server-side filtering by doing a parameterized query.
    Set the data connection NOT to automatically download
    Add Form Load rules that do the following:
    First, "Set a Field's Value" and set the position query node of the data connection to the value of "manager" (whatever the exact syntax is)
    Then query the data connection
    Doind this should make it ONLY download items where position=manager instead of downloading all items and filtering.  This is a much better practice and was not even available in 2007, so you should make full use of it in 2010.  Even so, what you
    were doing should have worked anyway, so I'm not sure what's going on there.
    When you do the filtered dropdown, your Source field should be the repeating group of the data connection, not the property itself.  The property should only be selected in Value and DisplayName.  The group should be in the Source field, and THAT'S
    where you apply the filter.
    SharePoint Architect || Microsoft MVP ||
    My Blog
    Planet Technologies ||
    SharePoint Task Force

  • SPSiteDataQuery - filter by file Title - Can I use variable for the filter value?

    I use SPsiteDataQuery to search across multiple lists and filter by file title. I have the file title information in a variable.
    Can I use variable in the filter value?
    string fileName = "Policies.doc"
    SPSiteDataQuery spQry = new SPSiteDataQuery();
    spQry.ViewFields = "<FieldRef Name='Title'/><Value Type='Text'>fileName</Value>"

    If I have understood correctly, you want to search based upon a File title in all the sites. You can include a query to filename in the spQry
    spQry.Query = "<Where>" +
    "<Eq>" +
    "<FieldRef Name=\"FileLeafRef\"/>" +
    "<Value Type=\"Text\">" + fileName + "</Value>" +
    "</Eq>" +
    "</Where>";
    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

  • Please help to build an sql from the given expression to build case condition with Where clause

    if  @rollno is not null then
    Select top  1 studentid  from student where rollno =:@rollno
    else
    if @regno is not null then
    Select top  1 studentid  from student where regno =:@regno
    Please help me to create  the above condition as  a single  sql statement . I will pass two argument in to the sql.
    With Thanks
    Pol
    polachan

    Select top 1 studentid from student
    where (rollno =:@rollno or :@rollno is null)
    and (regno =:@regno or :@regno is null)
    The above expression will work in SQL server
    I'm not sure you're using sql server as syntax like :@regno are not t-sql valid
    so you can try the above and if it doesnt work please try in the relevant forums for more help in case you're using a different RDBMS
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Using substring in the XPATH expression for Receiver Determination

    Hello, I need a little help please.  In my receiver determination, I have a condition and I need to do a "not like" check.   Basically, if the first three positions of the source field does not start with a specific code, then I need to execute the condition.   The condition editor does not support a "not like" operand, so I went to the XPATH expression editor.  I tried to used the XPATH substring function to get the first three characters and then do a "not equal" operand, but it doesn't appear to work.  There are not any runtime errors, but the condition is not executing.  Any ideas on this?  Does the XPATH expression support the substring function?

    Hi Jesse,
    Can you please explain what is the meaning of http:// in the statement
    /p1:PRODUCT/MATNRhttp://not(substring(.,string-length(.) - 2) = '123')
    Please explein, I am having same issue. It is not working here.In My case it is
    /p1:ORDERS01/IDOC/E1EDP01/E1EDP19/IDTNR[http://not(starts-with(.,\"D\"))]
    also tried with
    /p1:ORDERS01/IDOC/E1EDP01/E1EDP19/IDTNR[http://not(starts-with(.,'D'))]
    Thanks in advance!

  • How to use Prompts in the Filter created in Change Report Properties

    Hi all,
    I have created one Datetime prompt in Change report properties dialogue box.
    Now how can I use this same one in the filter ??
    Since I didn't get Surface and Prompt option for the Date field in the filter.
    Any help is appreciated.
    Thanks

    Actually problem is with Datatype..It was timestamp but it should be Datetime

  • How to call SQL in the filter condition

    Hi
    Booking dashboard report i need to filter order_date between this Quarter starting date and this Quarter end date.
    i have custom table data is available Quarter starting and Quarter ending date .
    how i can use filter.
    thanks

    looks like you need to filter the order date between the quarter starting date and quarter ending date making sure order date is always present between the quarter start date and quarter end date
    Create a sub report with one column order date and make order date is prompted.
    So now in the main report use advanced filter option and
    Take the quarter start date column and use advanced filter option on it. Use the filter results based on another request. You can specify quarter start date is greater than the selected order date(sub report order date column)
    and
    Take the quarter end date column and use advanced filter option on it. Use the filter results based on another request. You can specify quarter end date is less than the selected order date(sub report order date column)
    This way you can force the order date always between quarter start date and quarter end date columns
    Hope it helps
    Thanks
    Prash

  • SUMIF using OR in the conditional expression

    I understand how to use the SUMIF function using checkboxes in one column for the conditional expression. I do not understand how to use it if I want to use an OR expression to OR various string values.
    I want have a column called "Categories" which have a variety of string values in them like "Club" "Soccer" "School" "Church" "Home". I want to SUMIF the category is "School" or "Home". I wrote out my formula like this:
    =SUMIF(Invitations::Category,OR("School","Home"), Invitations::Total in Party)
    but it doesn't work. Suggestions? Thank!

    Hello
    The OR is the correct operator but, as far as I know, this kind of condition is not allowed.
    Only a single one like "=Home" or like "=church" is allowed.
    I don't know which are the other categories.
    Assuming that they are "smaller than the string "church" you may use:
    =SUMIF(Category,">=church",Total in Party)
    If they are greater than "Home" you may use:
    =SUMIF(Category,"<Home",Total in Party)
    If you want to sum the values whose category matches one of three values, an alternate soluce may be to use an extraneus column (named Aux) whose formula would be
    =OR(Category="church",Category="Home",Category="YK")
    the final formula would be:
    =SUMIF(Aux,TRUE,Total in Party)
    Yvan KOENIG (from FRANCE mercredi 16 janvier 2008 14:08:41)

  • SQL report - Chart filter expression

    I have a chart in an existing SCCM report that I want filter down to two or more collections, but the dataset is used in other charts on the same report, so I can't touch that.
    I've been trying to create a filter in the Chart Properties, and can limit it down to one collection without issue:
    Expression: [CollectionID]
    Operator: =
    Value: VI100016      (the collection that I am filtering on)
    I've tried to go into the Value fx and set an expression manually, example below, but this errors when I run the report.
    =(Fields!CollectionID.Value  = VI100016) Or (Fields!CollectionID.Value  = VI100017)

    Yep that's got it thanks, just ended up using the following which worked:
    Expression: [CollectionID]
    Operator: In
    Value: ="VI100016", "VI100017"

  • Can I play separate music content to different speakers using Airplay via the Airport Express?

    Can I play separate music content to different speakers using Airplay via Airport Express?

    If you mean can you simultaneously stream different audio sources to multiple speakers the answer is no. You can only stream a single source to one or more speakers.

  • How to group using SQL for the required output.

    hi all,
    i'm currently using oracle 10.2.0.4.0
    create table script :
    CREATE TABLE FORTEST
    ( gpno VARCHAR2(10 BYTE),
      classnumber  VARCHAR2(10 byte),
      age_min NUMBER,
      age_max NUMBER,
      amount NUMBER)insert statement:
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 01,0,29,1)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 01,30,35,2)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 01,36,40,3)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 02,0,29,1)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 02,30,35,2)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 02,36,40,5)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 03,0,29,1)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 03,30,35,2)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 03,36,40,3)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G124' , 01,0,29,1)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G124' , 01,30,35,2)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G124' , 01,36,40,3) output required:
    gpno    classnumber    age_min    age_max    amount
    G123    1,3                0        29        1
    G123    1,3                30       35        2
    G123    1,3                36       40        3
    G123    2                  0        29        1
    G123    2                  30       35        2
    G123    2                  36       40        5
    G124    1                  0        29        1
    G124    1                  30       35        2
    G124    1                  36       40        3since for gpno g123, classnumber 1 and 3, the rates are same across all age_min and age_max they need to be grouped together.
    even though gpno 123 classnumber 2 has same rates as classesnumber 1 and 3 for age bands 0 to 29 and 30 to 35,
    the rates are different for age bands 36 to 40. so it should not be grouped together. how can i do this in SQL
    any help is appreciated.
    thanks in advance.

    Hi,
    Tricky problem!
    Unfortunately, LISTAGG was only introduced in Oracle 11.2. About half of the complexity here is the string aggregation, that is, forming the list of classnumbers, such as '1,3', using only functions available in Oracle 10.2.
    Here's one solution:
    WITH     got_gpno_classnumber_cnt   AS
         SELECT     gpno, classnumber, age_min, age_max, amount
         ,     COUNT (*) OVER ( PARTITION BY  gpno
                                      ,            classnumber
                          )   AS gpno_classnumber_cnt
         FROM    fortest
    --     WHERE     ...     -- If you need any filtering, this is where it goes
    ,     pairs          AS
         SELECT    a.gpno
         ,       a.classnumber
         ,       MIN (b.classnumber)
                    OVER ( PARTITION BY  a.gpno
                              ,                    a.classnumber
                      )     AS super_classnumber
         FROM       got_gpno_classnumber_cnt  a
         JOIN       got_gpno_classnumber_cnt  b  ON   a.gpno     = b.gpno
                                      AND  a.age_min     = b.age_min
                                    AND  a.age_max     = b.age_max
                                    AND  a.amount     = b.amount
                                    AND  a.gpno_classnumber_cnt
                                            = b.gpno_classnumber_cnt
         GROUP BY  a.gpno
         ,            a.classnumber
         ,       b.classnumber
         HAVING       COUNT (*)     = MIN (a.gpno_classnumber_cnt)
    ,     got_rnk          AS
         SELECT DISTINCT     
                 gpno, classnumber, super_classnumber
         ,     DENSE_RANK () OVER ( PARTITION BY  gpno
                                   ,                    super_classnumber
                                   ORDER BY          classnumber
                           )         AS rnk
         FROM    pairs
    ,     got_classnumbers     AS
         SELECT     gpno, classnumber, super_classnumber
         ,      SUBSTR ( SYS_CONNECT_BY_PATH (classnumber, ',')
                       , 2
                     )     AS classnumbers     
         FROM     got_rnk
         WHERE     CONNECT_BY_ISLEAF = 1
         START WITH     rnk             = 1
         CONNECT BY     rnk             = PRIOR rnk + 1
              AND     gpno             = PRIOR gpno
              AND     super_classnumber  = PRIOR super_classnumber
    SELECT DISTINCT
           g.gpno
    ,       c.classnumbers
    ,       g.age_min
    ,       g.age_max
    ,       g.amount
    FROM       got_gpno_classnumber_cnt  g
    JOIN       got_classnumbers         c  ON   c.gpno        = g.gpno
                                 AND  c.classnumber  = g.classnumber
    ORDER BY  g.gpno
    ,            c.classnumbers
    ;Output (just as you requested):
    GPNO       CLASSNUMBERS       AGE_MIN    AGE_MAX     AMOUNT
    G123       1,3                      0         29          1
    G123       1,3                     30         35          2
    G123       1,3                     36         40          3
    G123       2                        0         29          1
    G123       2                       30         35          2
    G123       2                       36         40          5
    G124       1                        0         29          1
    G124       1                       30         35          2
    G124       1                       36         40          3

  • Insert multiple rows using sql at the same time

    I have searched a lot from the forum, but found nothing.
    There are two tables in oracle scheme: TableA(ID_A, column2,column3),
    TableB(ID_B, column2, column3); and TableA has multiply rows already, TableB is empty. TableB's ID_B has a
    Now I want to copy values from TableA.column2 and TableA.column3 to TableB.column2, TableB.column3.
    INSERT INTO SYSTEM_USER_GROUP (ID_user_group,ID_USER,ID_GROUP) values(((SELECT seq_system_user_group.NEXTVAL FROM DUAL),(SELECT U.ID_USER FROM SYSTEM_USER U),(SELECT U.ID_GROUP FROM SYSTEM_USER U)));
    ORA-00907: missing right parenthesis
    Any suggestion will be great appreciate!

    INSERT INTO SYSTEM_USER_GROUP (ID_user_group,ID_USER,ID_GROUP)
    (SELECT seq_system_user_group.NEXTVAL, ID_USER, ID_GROUP,
    FROM SYSTEM_USER)
    ORA-00936: missing expression
    ------------>>>
    I think that seq_system_user_group is a scheme level of oracle, so if you select it from a table, there will not work.
    Thank you all the same!
    Can i create that sequence as a column of one table? if that is the case, then my problem will be resolved.

  • Using the "IN" expression in SQL statement

    Hi,
    I have an array with multiple values stored in it. I would like to use these values in the filter expression of another query using the "IN" clause (data is coming from a sql dataabse). Is there a way to achieve this, I did not see an option in the std query template for using the "IN" expression.
    Thanks.

    Or, to save Params, pass in a comma separated list of match values:
    select * from mytable where mycolumn in ([Param.1])
    And if you are getting the comma separated list from say an iBrowser, here are two quick utilities to build a comma separated list of the iBrowser values or iBrowser Datalink values:
    // returns comma separated list of DATALINK values from iBrowser.
    // if none selected, returns list of all values
    function getCSLDatalinkValues(myApplet) {
         var selValues = "";
         var selCount = myApplet.getBrowserObject().getSelectedItemCount();
         if(selCount) {
              for(var i=1; i<= selCount; i++) {
                   selValues += myApplet.getBrowserObject().getSelectedDatalinkValueAt(i) + "','";
         } else {
              for(var i=1; i<= myApplet.getBrowserObject().getItemCount(); i++) {
                   selValues+= myApplet.getBrowserObject().getDatalinkValueAt(i) + "','";
         // remove trailing ","
         selValues = selValues.substring(0,selValues.length-2);
         // insert begin "'"
         selValues = "'" + selValues;
         return selValues;     
    // returns comma separated list of values from iBrowser.
    // if none selected, returns list of all values
    function getCSLValues(myApplet) {
         var selValues = "";
         var selCount = myApplet.getBrowserObject().getSelectedItemCount();
         if(selCount) {
              for(var i=1; i<= selCount; i++) {
                   selValues += myApplet.getBrowserObject().getSelectedItemAt(i) + ",";
         } else {
              for(var i=1; i<= myApplet.getBrowserObject().getItemCount(); i++) {
                   selValues += myApplet.getBrowserObject().getItemAt(i) + ",";
         // remove trailing ","
         selValues = selValues.substring(0,selValues.length-1);
         return selValues;     

Maybe you are looking for

  • XSLT Fragment question

    I am using an XSLT fragment in order to display an RSS feed on a webpage. The problem is that there is a large space at the top of my fragment. I would like to get rid of this space. Anyone know how to do this?

  • Xls/pdf Download Options not available in interactive report on group by

    Hello All, I have the similar problem like mentioned here: export from IR with group by there I didn't find any response, Please let me know why it is happening, is there any solution to this. thanks Tauceef Edited by: Tauceef on Feb 9, 2011 4:02 PM

  • Merging PDF's, what about settings?

    I have a little "problem"; I shall make a 2 sided folder for printing, and I have selected the right resolution, color-settings, color-mode(CMYK) and color-profile according to the print-shops demand. I have made 2 PDF's, one for the front-side, and

  • How do you Re-install Safari???

    I need to re-install my safari browser since my flash player is not working...and I'm guessing reinstalling it would help a bit... So if i delete safari from my computer, is there a way to reinstall it without wiping out my HD since i need my music a

  • What's up with RealPlayer support?

    I have installed Director 11.5 and downloaded the latest (and only available) version of realplayer (RealPlayerSP). Director does not recognize this new, latest RealPlayer version as a valid version and will not load media through the xtra.I guess th