Using previous results in a query

Hi
Please can someone assist.
I have a bex query - 1 structure only in my columns
I have my data in rows broken down by calendar year.
What I need to be able to do is to use the result in calendar year 2008 and sum it in calendar year 2009.
  Calendar month
  Calendar Year
  Remaiining
  Date of Hire
  Quota number
  Carry Over
  Deduction
MAY
2009
21.960
2000/05/15
21.960
0.000
21.960
2010
30.000
2000/05/15
30.000
0.000
30.000
2011
42.260
2000/05/15
42.260
0.000
42.260
2012
39.240
2000/05/15
33.240
6.000
27.240
2013
50.000
2000/05/15
25.000
25.000
0.000
JUL
2008
39.780
2000/05/15
39.780
0.000
39.780
DEC
2007
43.700
2000/05/15
43.700
0.000
43.700
Result
266.940
2000/05/15
235.940
31.000
204.940
My last column needs to be Entitlement which should be the carry over of 2012 + carry over of 2013 = 31 - which should be my entitlement for 2013.
Not sure if that makes any sense.
Please see images attached.
Is there a way to do this with no ABAP, as I am not able to write the customer exit.
Thank you

You may try with Cell definitions concept by introducing a "Calyear structure" in rows and define 2013 cell accordingly. Rest all cells other than in Entitle ment KF take the definitions of their respective CKFs/RKFs. Leave all cells blank other than 2013 in Entitlement KF.
Remove Calyear infoobject which is there currently in rows pane and then create a structure in place of it. Every year, you will need to enhance the Calyear structure and make the cell definitions accordingly as per your business requirement.
Please have a look at my blog to get a brief idea on what I am saying.
How to achieve Slab Wise or Bucket Wise and Age Wise requirements in BEx
Message was edited by: SumaN ChakravarthY K
Message was edited by: SumaN ChakravarthY K

Similar Messages

  • Can I use the result of a query in another query of the same cube?

    Hello everybody;
    I have the following case. In query "A", I have used in rows a structure, whit a last formula named “Total A”, in another query "B", I need to used the result of “Total A”.
    Can anybody help me?
    Thanks in advanced.
    Mariana Serrano

    Hi Mariana,
    You can change local structures into reusable structures in any existing query by selecting the structure and, choosing Save as... from the context menu and then entering a technical name and a description in the Save Structure as... dialog box.
    You can change reusable structures that you are using in a query into local structures by selecting the structure and choosing Remove Reference from the context menu.
    Also go through this link:
    http://help.sap.com/saphelp_sem40bw/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    Best Regards,
    DMK
    *Assign point if it helps...

  • Using the results of one Query in a workbook as a filter in another query

    Hello!
    I'd like to have one workbook which my users can execute and the result from one Query (e,g, Customer Account Number) will then be used as a filter in a second query (which would be from a different cube).
    Can this be done?
    Cheers.

    Hi,
    As far as I understand your requirement, you want to pass the result of one query to another query as a filter.
    Well you can do this, by Using Replacement Path Variable.
    For e.g. you want to pass Values of Custmomer Account Number to another query. In the second query, create one variable on Customer Account Number with type Replacment Path. Here it will ask you to enter the name of the query from which you would like to take the values of Customer Account Number.
    When you will run the second query , it will execute the first query from which you want to read the customer accoutn number in the back-end. And it willl display the output the second query as per the valeus of customer account number.
    This will help.
    - Jaimin

  • Need to use the results of one query as an input to another query

    Hi, I have one sql query in my XML file, that returns more than one values for a column.
    and i want to use this output one by one as an input to the second query to retrive the data from the second query.
    Could please someone tell me if its possible in XML Publisher?
    If possible, please share the syntax to do the same
    For eg:
    Query 1:
    Select data1, data2 from query1 ; -- output data1 and data2
    want to use data1 and data2 one by one in the below query
    Query 2:
    select * from abc where name_id= data1/data2;
    Thanks and Regards
    Madhu

    Make sure your cursor declarations are in your declare section, not between the begin and end statements.

  • Unicode String Issue while Using Results from Another Query

    Hi All,
    In a webi report i have 2 queries say Sales Out and Investment. I need to have only those chains which are in Investement in Sales Out.
    So in Sales Out query i am using the option Results from another Query. The Chain values are in Unicode format.
    Though in universe i have Set Parameter Unicode_String ='Yes', this does not get applied when using option Results from another Query.
    Is there any solution to resolve this problem.
    Thanks
    Madhura

    leonhardtk wrote:
    I need to take values from the column of one table that meets certain critera, and create inserts into another table that includes this data.
    For example...
    {code}
    select emp_last_name from emp where emp_first_name like 'B%';
    Duncan
    Fitzgerald
    Johnson
    Smith
    {code}
    I then want to insert these values into another table:
    {code}
    insert into My_table values (
    sequence.nextval,99,99,[last_name]);
    {code}
    In the example above, I need it to insert a new row into My_table for where the "last_name" is each of the names from the select statement above (Duncan, Fitzgerald,Johnson,Smith).
    Based on other similar forum questions it looks like I should be doing something like:
    {code}
    INSERT INTO MY_TABLE
    (SELECT sequence.nextval,
                    99,
                    99,
                   (select EMP_LAST_NAME
                    FROM EMP
                    WHERE EMP_FIRST_NAME LIKE 'B%')
    {code}
    But this (obviously) doesn't work!
    Appreciate any assistance on this!
    KSL.
    Hi,
    Created this test data
    create table plch_test (name varchar2(50));
    insert into plch_test values('AKSHAY');
    insert into plch_test values('RAHUL');
    insert into plch_test values('APARNA');
    output
    1    AKSHAY
    2    RAHUL
    3    APARNA
    created another destnation table(in your case "my table")
    create table plch_test_1 (id number,name varchar2(50));
    created another sequence to generate employee ids
    create sequence test_seq;
    Now populated the desination table
    insert into plch_test_1(select test_seq.nextval,name from plch_test);
    verify the destination table
    select * from plch_test_1
    1    AKSHAY
    2    RAHUL
    3    APARNA
    Hope this helps
    Regards,
    Achyut Kotekal

  • Query on results from another query

    Post Author: Duncan1980
    CA Forum: Crystal Reports
    Is it possible to query on the results from another query.  I have a query that produces a list of document numbers.  I want to use the output from that query as the filter criteria in a another query in the same Universe. 
    The output from the first query can be as much as 2000, so it would be very time consuming to cut and paste these into a filter.
    Both reports are built, but can not figure out how to link the first report output to the filtering criteria on the second report.  I
    I am using business objects XI release 2 web intelligence 11.5.3.417 enterprise.

    Hi Vivek,
    It was not directly solved but I applied alternate logic to over come the issue.
    Here's what I did to overcome:
    I used a sub query in place of the whole result from another query.
    For Ex:
    Dim1 inlist result from another query1
    I made it as
    Dim1 inlist (Dim0)
    where Conditions.
    Here Dim0 is the object which we use for Result from another query and Conditions will be the necessary filter conditions to arrive proper Dim0.  Make sure proper context is formed for the sub query.
    Even though it resolved my problem, It introduces an new issue. It causes increase in query run time when huge set of data is returned from sub query.
    Please let me know if i haven't explained clearly.
    Hi Aris_BO,
    Sorry for not responding earlier.  The logic would probably make more queries null & not null. Thats why I was not advised to use it.
    Thanks
    LN

  • Issue with Results from Another Query (Error on Null value)

    Hi All,
    We have a WebI report using "Result from Another Query" option of BO XI R3.1. The report was running fine till recently the dimension object using result from another query had a null value. Report suddenly throwed error as the query filters are invalid.
    Is there a way to make this filter optional if no data/null value is there ? Because we need those null values in report as well.
    Thank you for your time.
    Thanks & Regards
    LN

    Hi Vivek,
    It was not directly solved but I applied alternate logic to over come the issue.
    Here's what I did to overcome:
    I used a sub query in place of the whole result from another query.
    For Ex:
    Dim1 inlist result from another query1
    I made it as
    Dim1 inlist (Dim0)
    where Conditions.
    Here Dim0 is the object which we use for Result from another query and Conditions will be the necessary filter conditions to arrive proper Dim0.  Make sure proper context is formed for the sub query.
    Even though it resolved my problem, It introduces an new issue. It causes increase in query run time when huge set of data is returned from sub query.
    Please let me know if i haven't explained clearly.
    Hi Aris_BO,
    Sorry for not responding earlier.  The logic would probably make more queries null & not null. Thats why I was not advised to use it.
    Thanks
    LN

  • How do you use BOBJ SDK to retrieve the results of a query in XML

    I am trying to programatically get the results of a query given the query id
    My old code used BusinessObjects Enterprise Web Services API to  Retrieve a document's contents
    DocumentInformation biDocInfo;
    RetrieveData retBOData = RetrieveData.Factory.newInstance();
    Action[] actions = new Action[1];
    retBOData.setRetrieveView(xmlView);
    biDocInfo = rEngine.getDocumentInformation(queryId, null, actions, null, retBOData);
    (XMLView) biDocInfo.getView();
    Is there an equivalent way to retrieve the results of the query using SAP BusinessObjects BI 3.x Developer SDK Library ?
    Thanks for any information

    Hello.
    Are you wanting to use the BusinessObjects Enterprise SDK along with the Report Engine SDK as opposed to using the Web Services SDK that you were using previously?
    Also, what part of a webi document are you trying to get the XML format of?
    - Whole document
    - Single report within a document
    - Report page of a report
    - Report part within a report
    - All data providers
    - Single data provider
    If you are trying to use Business Objects Enterprise along with the Report Engine SDK, there are numerous samples for the various parts of the webi document that I mentioned above available at the following link:
    http://wiki.sdn.sap.com/wiki/display/BOBJ/JavaReportEngineSDKSamples
    I hope that this information helps.
    Regards.
    - Robert

  • How to use Results from Another Query for SAP BW universes

    Hi Everyone,
    I have two SAP BI universes.In my First universe I have Sales Doc no (dimension) and Orderqty (Measure) and in my second universe I have Sales Doc no(Dimension) and BillQty (Measure).
    Here in my first dataprovider I have 1200 rows of data and in second dataprovider I have 75,000 rows. The report should fetch only the BillQty details that matches to corresponding  Sales doc no in first data provider.
    I want to place all these fileds into a single report like as shown.
    (Datarpovider1)                (Datarpovider1)                    (Datarpovider2)
    *Sales Doc No*               Orderqty                           BillQty
    Here I am able to generate single report using merge dimension but it is leading to performance issues. I want to restrict the values at query level by passing the First dataprovider Sales doc no to second Data provider Sales doc number using Results from Anothery Query feature so that It can fetch only the matching records.
    I tried it but it was giving the follwing error:
    A filter contains a wrong value. You cannot run this query. (Error: WIS 00007)
    How Can I get rid of this error. Can we use Results from Anothery Query option for OLAP universe. Are there any limitation on it.
    All this I am doing in Webi Rich Client.
    Appreciate your help
    Thanks &in Advance
    Kiran Saka

    Hi Kiran,
    I think the filter has a wrong operand. For example, a filter with an empty constant, or a filter that deals with numeric values is defined with an alphanumeric value.Check out for this.
    Regards,
    Neeraj

  • How to use one query results in another query

    hi,
    in help.sap I have founded that using variable type replacement path I can use one query results in another query. It is wrote there that I have to choose query name results I want to get in variable definition but I do not know where.
    How I can do this?
    Result I want to get is:
    In one query I have material prices in another material quantities. I want to calculate inventory value (price * quantity). Moreover prices are on plant level, quantities on storage type level. Plant is atribute of storage type.
    Can I do this?
    Regards,
    Andrzej

    Hi Andrzej,
    please check out this thread: Set parameters values depending on other parameters
    I had a discussion about query results as input for another query in there.
    For creating a workbook, just click on the save button after you ran your query in the bex.
    Siggi
    Message was edited by: Siegfried Szameitat

  • Is it possible to put the results from a query in a variable to use in the bean class?

    Hello, I'm using JDeveloper 12.1.2.0.0
    I would like to keep the result of my queries (the method i created in the AppModule) in a RichTable or other type of variable so i can have the results stored and i don't have to do unnecessary queries after. I don't think the query is the problem but keeping the results.
    I've tried to do that by using this:
        public String testVFactSales(String conditions) {
            PreparedStatement query = getDBTransaction().createPreparedStatement("" + "select * from v_fact_sales " + conditions, 0);
            //ResultSet rs;
            ResultSet result;
            //RichTable result;
            //String result = null;
            try {
                //query.setString(1, conditions);
                // query.execute();
                query.execute();
                result = query.getGeneratedKeys();
                query.close();
                System.out.println("Result: " + result.toString());
                return result.toString();
            } catch (SQLException e) {
                e.printStackTrace();
            return "";
    As you can see, i've already tried some solutions but so far i only get errors (cannot convert or null exception, when i try to put the result in a richtable in my bean class)
    Any ideas?
    This is very important for me, since it would improve the performance of my project a lot.
    Regards,
    Frederico.

    Hey Arunkumar,
    I came to this conclusion since i'm using binding variables with my where clauses.
    I've measured the time and i get really bad time responses.
    This is my main table query, where all the others selections will be filter the search in this table:
    SELECT VFactSalesNew.N_SALES,                              
           VFactSalesNew.QUANTITY,                              
           VFactSalesNew.PRICE,                               ,                              
           VFactSalesNew.FK_STORE,                              
           VFactSalesNew.ID_ANO,                              
           VFactSalesNew.QUARTER   
    FROM V_FACT_SALES_NEW VFactSalesNew                              
    WHERE                                          
    ((nvl(:var_dimCoin,'0') ='0' OR FK_COIN IN (select * from THE(select cast( in_list(:var_dimCoin) as mytableType ) from dual ) a) )                                                   
    AND                                                 
    (nvl(:var_dimProduct,'0') ='0' OR FK_PRODUCT IN (select * from THE(select cast( in_list(:var_dimProduct) as mytableType ) from dual ) a) )                                                  
    AND                                                 
    (nvl(:var_dimCustomer,'0') ='0' OR FK_CUSTOMER IN (select * from THE(select cast( in_list(:var_dimCustomer) as mytableType ) from dual ) a) )                                                 
    AND                                                 
    (nvl(:var_dimStore,'0') ='0' OR FK_STORE IN (select * from THE(select cast( in_list(:var_dimStore) as mytableType ) from dual ) a) )                                                
    AND                                                 
    (nvl(:var_dimSeller,'0') ='0' OR FK_SELLER IN (select * from THE(select cast( in_list(:var_dimSeller) as mytableType ) from dual ) a) )                                                  
    AND                                                 
    (nvl(:var_dimProject,'0') ='0' OR FK_PROJECT IN (select * from THE(select cast( in_list(:var_dimProject) as mytableType ) from dual ) a) )                                                  
    AND                                                 
    (nvl(:var_ano, '0') ='0' OR ID_ANO IN (select * from THE(select cast( in_list(:var_ano) as mytableType ) from dual ) a) )                                                  
    AND                                                 
    (nvl(:var_treemap,'0') ='0' OR PK_REGION IN (select * from THE(select cast( in_list(:var_treemap) as mytableType ) from dual ) a) )                                                  

  • Use the results of an SQL query to create another query

    I am working on a bidding/allocation system using C# and MySQL, and I am currently having difficulty implementing the “post-allocation” mechanics of the system. Let me explain how it works, before introducing the code:
    When the bids are made on the system, they all have the position 0, so the first thing the system does is order them according to priority.
     (bid table)
    In this case, 5 bidders are interested in what is in plot 15, but we have not assigned them a position yet.
     (bid table)
    The system then organises the bids according to the order in which they are going to processed.
    The bids are then allocated, but unfortunately there are only 3 spaces in plot 15 that can be allocated. As a result, we use the priority listing to determine which bidder gets what.
     (booking table)
    At this stage, I can say that I am stuck, there are two things that I want to do, both of which involve reusing the results of the query at step 2.
     (bid table)
    The bidders that have their job allocated should see: their bid.status updated
    from Queued to Allocated,
    the bid.position should
    be set to 0,
    and their job_id should
    be set to the booking they have been allocated (i.e. booking.id).
    The bidders that have not had their jobs allocated should see: their bid.status remain
    as Queued, and their bid.position should
    be set to 0 in
    preparation for the method to run again
    The difficulty I am having is in stage 3, how do I determine which jobs have been allocated and which ones have not, and then run the necessary SQL queries in order to make the updates?
    My code so far is as follows:
    // STEP 1a - SELECT BIDS
    string query =
    "SELECT t1.operator_id, t1.datetime, t1.plot_id, t1.position, t2.market_access FROM bid t1 " +
    "JOIN operator t2 ON t1.operator_id = t2.id WHERE t1.status='Queued' AND t1.postcode=@postcode " +
    "ORDER BY t2.market_access ASC, t1.datetime ASC";
    var bidList = new List<BidList>();
    var cmd = new MySqlCommand(query, _connection);
    cmd.Parameters.AddWithValue(("@postcode"), _plot);
    MySqlDataReader dataReader = cmd.ExecuteReader();
    while (dataReader.Read())
    var item = new BidList
    OperatorId = dataReader["operator_id"] + "",
    PlotId = dataReader["plot_id"] + "",
    Position = dataReader["position"] + "",
    Datetime = dataReader["datetime"] + "",
    MarketAccess = dataReader["market_access"] + "",
    bidList.Add(item);
    dataReader.Close();
    // STEP 1b - SET PRIORITIES
    for (var i = 0; i < bidList.Count; i++)
    var position = i + 1;
    bidList[i].Position = position.ToString();
    query = "UPDATE bid SET position=@position WHERE status='Queued' AND postcode=@postcode AND operator_id=@operator_id;";
    cmd = new MySqlCommand(query, _connection);
    cmd.Parameters.AddWithValue(("@position"), position);
    cmd.Parameters.AddWithValue(("@postcode"), _plot);
    cmd.Parameters.AddWithValue(("@operator_id"), bidList[i].OperatorId);
    cmd.ExecuteNonQuery();
    dataReader.Close();
    // STEP 2 - ALLOCATE JOBS ACCORDING TO PRIORITY
    foreach (var t in bidList)
    query = "SELECT operator_id, plot_id, status FROM booking " +
    "WHERE status='open' AND postcode=@postcode AND operator_id='0'" +
    "ORDER BY datetime ASC;" +
    "UPDATE booking SET operator_id=@operator_id, status='Allocated' " +
    "WHERE (plot_id=@plot_id AND operator_id='0' AND status='Open') LIMIT 1;";
    cmd = new MySqlCommand(query, _connection);
    cmd.Parameters.AddWithValue(("@operator_id"), t.OperatorId);
    cmd.Parameters.AddWithValue(("@postcode"), _plot);
    cmd.Parameters.AddWithValue(("@plot_id"), t.PlotId);
    cmd.ExecuteNonQuery();
    dataReader.Close();
    // STEP 3
    CloseConnection();

    I can't tell.  When modifying row(s) you have to be able to uniquely be able to identify the row(s) in the database you want to modify.  That is why I recommended the other day to use DataAdapter instead of the DataReader.  You can with the
    reader, but you need to unique identify the rows.
    I can't tell from the limited amount of data you posted if in table 2 that there is only one row with the same operator id and plot id.  It looks like in table 2 the 'id' number is unique.  When working with a database with multiple tables you
    need to be able to link tables together with primary keys (columns wit unique values).  If the database isn't designed properly then it is impossible to do some operations.  So you always have to make sure you design a database properly.
    jdweng
    When you say table 2 are you referring to the bid or booking table?
    Here is the table structure for the bid table
    Here is the table structure for the booking table
    Hope it helps makes things clearer!

  • Can we use Result from another query in Webi using Bex uery universe?

    Hi,
    Can we use Result from another query filter option in Webi to create a report using a Bex Query universe?
    I need to create a report using two universes, one is Bex Query Universe and the other is Orcle universe. I have two queries, one is using Oracle universe; the other using Bex Query universe. I need to pass the Oracle data from the Oracle query to the Bex Query query to get the matched data from SAP Bex query.
    I used Result from another query in the query filter panel for the query using Bex query universe. But I got an error saying that 'A filter contains a wrong value. you cannot run this query. (Error: WIS 00007). The data used in the filter on both sides are the same. they are char.
    I have tested by using two queries from the same Bex query universe to see if the Result from another query filter option works. And I got the same error.
    Has anyone run into the same issue and if this is possible and what should be the solution?
    Thanks in advance!
    Edited by: BO_Haiyan on Oct 6, 2010 3:47 PM

    In that situation:
    Create two queries : Oracle and BW query.
    @ Report:
    As you have to see result set from both the Dataproviders, correct? To achieve thise one must have common dimension objects to merge them at report and use Objects those are coming from both queries to use them in single Table/Report.
    Unless you don't use Merge Dimensions, you don't get a chane to use both queries objects in single Table/Report. (It will give tooltip saying: You can't drop here -- Incompatable Objects)
    In case, if you don't have common dimensions, change object definitions to Detail objects, for those required.
    Hope it helps you.
    Thank You!!

  • How to use the result of a sql query for a max () function

    Hi
    I wrote a query on which i wrote
    "select max(id) from users "
    how can i use the returned value.
    if i made the var name ="userid"
    can it be userid.rows[0] or what.
    thnx for any help

    Hi!
    The result of this query will be the max ID of users' IDs.
    Let say we have:
    String sql="select max(users.id) from users";
    Statement st = ctx.conn.createStatement();
    ResultSet rs = st.executeQuery(sql);
    rs.next();     
    So you can get the max Id in the following way:     
    int maxId=rs.getInt("id");
    Regards,
    Rossi

  • Performing calculations on characteristics, using the results as query rows

    I want to perform a calculation on 2 date fields (find the number of years separating the dates). These 2 date fields are characteristics. I want to use the result field as a row in the query. How to do this?
    Do I have to use a calculated key figure and then converted that key figure into a characteristic to use in a row?
    Thanks
    Sanjeev

    Hi,
    You need to use the Condition on this Date difference column.
    http://help.sap.com/saphelp_bw31/helpdata/en/73/702e39074dc93de10000000a114084/frameset.htm
    With rgds,
    Anil Kumar Sharma .P
    Message was edited by:
            Anil Kumar Sharma

Maybe you are looking for