Calculation of % in Query

Hi All,
I am having below work in my query.
I am having 'Region' in my Row and 'Production' in my coloum. And there are two key figures in the coloum.
Now my report is like below format.
Product Form             A                  B            C             Overall Result
Region         KeyFg1   (%)KeyFig2   
1                    10          10%60
2                    20          20%60
3                    30          30%60
Overall           60                                                                
Result
Now, i want to calucate keyfigure 2 as shown in above . I want to calculate percentage as shown above.
Please suggest, how to implement the same.
Regards,
Macwan James.

Hi James,
Since you have already tried most of the options, try this one too:
If 'Region' is the most granular characteristic in the query (that is, it is on the right most level in the list of rows);
1) Create a CKF 'KF1 Agg'
2) In it, add  SUMCT 'KF1'
3) Then create a CKF 'KF2'
4) In it add   KF1 %A 'KF1 Agg'
This will work, since 'KF1 Agg'  does not take the entire result but only the total of 'KF1' for all the regions.
Hope this helps.
Regards,
Shruti.

Similar Messages

  • Mathematical calculations in ABAP Query

    Dear gurus
    Can I perform mathematical calculations in ABAP Query?
    Kingly guide
    MK

    Hi
    You would need tables - AFPO, AUFM, MSEG, MAKTX (if you need mtl description).
    Use AFPO table to pass your FERT material number, then read the order numbers for this order.
    Now in AUFM there is an Index on AUFNR field, so you can pass all the order nos. of the FERT to this field.
    If you want to limit for a certain period, then use AUFM-BUDAT which is the posting date.
    Now add all the 261 movements for which there is no 262 movement, you can check for reversals in MSEG table. This you can do per component & display the data as per your need.
    Regards,
    Vivek
    Added
    You can get this info in COOIS report as well, by selecting List option as Documented Goods Movement & by using suitable filter options.

  • Effect of Restricted Keyfigure & calculated keyfigure in query performance

    Hi,
             What is the effect of Restricted Keyfigure & calculated keyfigure  in Query Performance?
    Regards
    Anil

    As compared to formulas that are evaluated during query execution, calculated key figures are pre-calculated and their definitions are stored in the metadata repository for reuse in queries. The incorporation of business metrics and key performance indicators as calculated key figures, such as gross profit and return on investment (which are frequently used, widely understood, and rarely changed), improve query performance and ensure that calculated key figures are reported consistently by different users. Note that this approach improves query runtime performance but slows InfoCube or ODS object update time. As a rule of thumb, if multiple and frequently used queries use the same formula to compute calculated fields, use calculated key figures instead of formulas.
    RKFs result in additional database processing and complexity in retrieving the query result and therefore should be avoided when possible.
    other than performance, there might be other considerations to determine which one of the options should be used.
    If the RKF's are query specific and not used anywhere in majority of other queries, I would go for structure selections. And from my personal exp, sometimes all the developers end up with so many RKF and CKF's that you get easily lost in the web and not to mention the duplication.
    if the same structure is needed widely across most of the queries, that might be a good idea to have global structure to be available across the provider, which might considerable cut down the development time.

  • Local Calculation (Summation) in query doesn't display correctly in web

    Hi All,
    I have been working on a complicated query where I have formulas that perform calculations.  I then Hide these formulas and use them in another formula for further calculations.  The new calculations I then use local summation to basically just add the columns values and come up with an overall result.  Works perfect and is displayed perfectly.
    Problem is now in the web.  Either using a Pie Chart or just simply an Analysis item, the values are not displayed correctly at all.  The Pie Chart only displays the first row of data (not the overall result...which is a local summation...which is what I would prefer) and suprised that the Analysis item doesn't basically display what the query does.  I'm guessing it has to do with this local calculation.
    Can someone explain this behavior?
    Thanks.

    Anyone any ideas?

  • Calculations Using SQL Query

    Hi All,
    I am using Oracle Database Version 11.2.
    I have a formula (A-B)/[(A-B)/10]. The tables that are holding the rows for this calculations are given below:
    ROWS_TAB
    ====== ===================
    Row          Amount
    ====== ===================
    A            5000
    B            -5000
    FORMULA_TAB
    ======== =========== ======== =============
    | ROW#  | Operator            | ROW        |   CONSTANT   |
    ======== =========== ======== =============
    | 10        |     E                   |      A       |                         |
    | 20        |     -                    |     B        |                         |
    | 30        |     E                   |      A       |                         |
    | 40        |     -                    |     B        |                         |
    | 50        |     /                    |               |      10                |
    | 60        |    /                     |               |                          |
    ======== =========== ======== =============
    The operator E starts a new calculation. The above formula has two sub-expressions thereby the table has two rows with E. Minus denoted by -, Plus denoted by +, Multiply denoted by *, and Division denoted by /.
    I want to write single SQL query to perform this calculation. Is it achievable in SQL?
    The scripts used to generate the tables are as below:
    create table ROWS_TAB
    (row_name VARCHAR2(1),
    amount NUMBER);
    create table FORMULA_TAB
    (row# NUMBER,
    operator VARCHAR2(1),
    row_name VARCHAR2(1),
    constant NUMBER);
    INSERT INTO ROWS_TAB VALUES('A', 5000);
    INSERT INTO ROWS_TAB VALUES('B', -5000);
    INSERT INTO FORMULA_TAB VALUES(10, 'E','A',null);
    INSERT INTO FORMULA_TAB VALUES(20, '-','B',null);
    INSERT INTO FORMULA_TAB VALUES(30, 'E','A',null);
    INSERT INTO FORMULA_TAB VALUES(40, '-','B',null);
    INSERT INTO FORMULA_TAB VALUES(50, '/','',10);
    INSERT INTO FORMULA_TAB VALUES(60, '/','','');
    Can anyone help in writing SQL query....
    Thanks in advance
    Best Regards
    Bilal

    As Frank said, it would be much easier to simply input the formula. Then, assuming you have OLAP option:
    variable formula varchar2(30)
    exec :formula := '(A-B)/((A-B)/10)';
    with t as (
               select  *
                 from  rows_tab
                 model
                   dimension by(row_number() over(order by row_name) r)
                   measures(
                            row_name,
                            amount,
                            count(*) over() cnt,
                            cast(:formula as varchar2(4000)) formula
                   rules(
                         formula[any] order by r = replace(nvl(formula[cv() - 1],formula[cv()]),row_name[cv()],amount[cv()])
    select  :formula || ' = ' || dbms_aw.eval_number(formula) result
      from  t
      where r = cnt
    RESULT
    (A-B)/((A-B)/10) = 10
    SQL>
    And if you do not have OLAP, you could use xquery:
    with t as (
               select  *
                 from  rows_tab
                 model
                   dimension by(row_number() over(order by row_name) r)
                   measures(
                            row_name,
                            amount,
                            count(*) over() cnt,
                            cast(:formula as varchar2(4000)) formula
                   rules(
                         formula[any] order by r = replace(nvl(formula[cv() - 1],formula[cv()]),row_name[cv()],amount[cv()])
    select  :formula || ' = ' || xmlquery(replace(formula,'/',' div ') returning content) result
      from  t
      where r = cnt
    RESULT
    (A-B)/((A-B)/10) = 10
    SQL>
    SY.

  • Linking to an Access Database (accdb) - calculated field in query

    Using Crystal Report v 14 we have a problem linking to an Access 2010 database (accdb file format).
    We created a query in the Access database with a calculated field that we want to use to link with Great Pllains database. We can see the query using the database expert and the OLEDB (ADO) data source. The problem is that the calculated field in the Access query does not show in the link manager.
    What is the best wat to link an Access table that has a job number containing hyphens (111-222-333) with the other database that has the job number stored without hyphens (111222333)? Why does our query solution not work?

    Hi,
    I'm not sure if this can be handled at the Database query level, however this can surely be handled from the report level.
    You would need to insert a subreport with Great Pllains as its datasource. The Main report's data source would be the access table.
    Next, in the Main report you would need to create a formula to remove the hyphens from the string and convert it back to number. Use this formula:
    tonumber(replace(,"-",""));
    You can then palce this formula in the details section/group section (which ever is applicable) and then link the subreports's job number field with this formula field. A record selection formula is automatically added in the subreport when you do so.
    Also, make sure the sub-report is place in the same section this formula field is placed in, otherwise you can get unexpected results.
    Hope this helps!
    -Abhilash

  • Variable to store a result of a complex calculation in bex query

    Hello all,
    I've got a query in BEX with some key fields to display and also need to perform some calculations not supported in bex formulas.
    I think this could be made in a BEX user exit and I'm trying this by creating a project in CMOD assigning EXIT_SAPLRR0_001... Working with INCLUDE ZXRSRU01 and so on.
    I just want to know if this is possible this way because I execute my query and the variable created never get any value at runtime.
    Could anybody help me or give an idea on how to use BEx user-exits?
    Thank you very much,
    Carlos Hinestrosa.

    Hi!
      I think it should work .here are some links to help topics on using user exits.
    presentations
    https://websmp206.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=011000358700005475091999E
    Help:
    http://help.sap.com/saphelp_nw04/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    propably they might help you
    With regards
    Ashwin

  • Question about calculation example with Query Designer

    Hi guys,
    I have to calculate within columns and rows and I am not familiar with the settings in Query Designer that could be done to achieve the results.
    For example:
    Payments----
    Delay -
    Weighted Delay
    1000USD--10 days--
    10000
    2000USD--20 days--
    40000
    3000USD--xxx--
    50000 (this is the sum row)
    The column marked with the xxx is calculated with the sum of weighted delay divided by the sum of payments (50000 / 3000).
    Has anybody an idea how the sum row can be calculated separately?
    Thank you for suggestions!
    Edited by: saplaz on Jul 13, 2010 8:47 AM
    Edited by: saplaz on Jul 13, 2010 9:08 AM

    Hi,
    Assuming you have the Payments Infoobject in the rows and WD Infoobject in the columns; Delay as a formula object.
    > Payments----
    Delay -
    Weighted Delay
    > 1000USD--10 days--
    10000
    > 2000USD--20 days--
    40000
    > 3000USD--xxx--
    50000 (this is the sum row)
    > The column marked with the xxx is calculated with the sum of weighted delay divided by the sum of payments (50000 / 3000).
    You may try this workaround of using
    NODIM( SUMCT(WEIGH_DELAY) / SUMCT(PAYMENTS) )
    on a formula variable. (In this case, the assumption is you have not static type-restricted the rows/cols) If you find any hinderances in the default approach, you may check this out as a formula & insert this at the cell editor level.
    If not, use a simple formula variable; here define the replacement path as 0(N) for your Payments. (N being the # of digits)
    Use a simple calculation:
    SUMGT(WD)/FV
    But you may not get an result o/p in the last row, as the values are not linked (sans relation with Payments). as it will return a X for the delay in the Result row.
    Pls. let me know know if this works or some sample o/p if the initial assumption was wrong.
    Thanks,
    Arun Bala

  • Creating a ad-hoc calculation using sql query

    Hi All,
    I want to know if its possible some way to create a ad-hoc sql query inside a workbook so as to create a calculation using that sql.
    I have a folder which gives me balance for any period. My requirement is to display current period balance along with prior years closing balance in same record for each code combination. I dont want to modify folder definition.
    Thanks for your inputs.
    Vishal.

    You could try creating a custom function for this purpose. You would need to register the function in the End User Layer and then you can call the function from your report.

  • Avoiding miscalculation of calculated item in query mode

    Hi:
    Imagine an invoice data entry system. 2 Blocks... the master (orders) and the detail (order_products). In the master you have the customer info and all that usual data... the details are the lines of products that this customer bought (quantity, price, etc) .
    Now imagine that I have calculated items that do the sum of the values from the lines and that are saved in the totals of the master block. And these calculations work very well...
    UPS... no they don't!
    Now imagine an order with 5 lines of products. Now imagine that you open that order and you go to the detail block and query that block and execute the query and the query only returs one or two lines for instance. The calculated items will change it value for the sum of the prices of these only 2 lines... but the order has 3 more products... and imagine that you click save... now the order totals are miscalculated...
    My question... HOW Can I avoid this? It's crucial!!!
    Best Regards
    Joao Oliveira

    Hi gerd :
    May a pre-commit-trigger selects the values from the database including the updated rows in the form?
    These computations are very very difficult. The values of the master table depends on the detail tables and the opposite is also true. By implementing triggers it will not work cause at the time the trigger fires in the master table the values from the detail table are not yet updated. This is a tricky issue...
    If I could avoid querying clauses in the detail block and avoid for instance the Clear_Record key... it would solve part of my problems.
    BR
    Joao

  • AND Calculation in a query

    Data in the infoprovider
    Order|Status|Amount
    123     ABC    10$
    123     DEF    10$
    124    ABC     10$
    Final Amount is the amount if the Order has both statuses only ABC and DEF.
    Results
    Order  Final Amount
    123   10$
    It should not show Order 124 as it has no DEF status and should show only Order 123 as it has both statuses ABC and DEF.
    How can we do this in a BEx query ?

    Hi Samuel M,
                            Could you restrict with status "def" in your query hope this will help you.
    Thanks,
    Vijay.

  • Calculation in Bex Query

    Hello Experts,
    I am developing a report with Bex and I would like to achieve the following:
    I have 0fiscper on the rows and sales amount KF on the columns. When I run the report, I get the following results:
                  Sales
    001/2006      40000
    002/2006      35000
    003/2006      60000
    xxxxxxxx
    Overall Result xxxxx.
    I would like to be able to calculate % sales for each period / cumulative sales YTD * 12 /number of periods. The Overall Result is what gives me the cumulative YTD sales but my question is:
    How can I use the period in the calculation? Any help would be greatly appreciated.

    hi Rue,
    what's no of period here ? total period (12 or 16) ? of total of period displayed like in your sample is 3 period ?
    you can use %GT (percentage of overall result),
    try to create 2 calculated keyfigures,
    one to hold number of periods, and the other for the calculation,
    - if you mean total period displayed, right click 'keyfigures' and 'new formula', give description e.g 'no of period', and type in 1 in formula area
    - 'new formula' again, double click 'percentage of overall result' in percentage function (you will see %GT), and drag 'sales amount' kf to formula area, then 12 * 'no of period', you formula may look like
    %GT 'sales amount' * 12 / 'no of period'.
    to set decimal places, right click the ckf and properties.
    hope this helps.

  • Calculation Field in Query

    Hi,
    I am devloping a query report of the confirmation details of process order.
    In which the execution start/finish date & time are confirmed during the confirmation process.
    The report of the same can be derived from COOISPI under operations.
    But, I want to calculate the duration on the basis of start/finish date & time. which is not available in standard COOISPI report or in table.
    I have created the query using the same tables as in COOISPI - operations. And now, I want to add an extra field which is not a part of the table. Also, how to assign a formula = (end date+end time)-(start date + start time)?
    I am not an ABAP person. I am just a simple PP/QM person. So, I don't know more about the same.
    Thanks in advance.
    Dipesh

    Hello Dipesh,
    You need to create an additional field.  Did you create an Infoset for this query (transaction code SQ02). 
    1.  After you create your table joins, select pushbutton labeled "Extras."  Select create icon, then enter field name and select radiobutton "Additional field" on popup box for Additonal information.  On popup box "Additional field" enter the new field text information, type and length.
    2.  You should see your new field in a list on the right-side of screen.  Select "CodingforAddition" icon.  Program your logic here.
    3.  Make sure you add your new field to a field group.  Generate your infoset. 
    4.  Call transaction SQ03 and assign your Infoset to a user group.
    5.  Call transaction SQ01 and create a query based on the Infoset you created.
    Kind Regards,
    Rae Ellen Woytowiez

  • On which object the "Last data update" is calculated when a query is built

    Can anybody tell me that the information "Last Data Update" (in a  query output) comes from which object ? I want to know the technical details .
    I know that if a query is built on a Multiprovider, then the "Last Data Update" will show the least loaded request date among the Infoproviders. But I want to know which object keeps this information.

    Hi Papiya,
    I think it is related to text elements SYUSEIT and also to 0REQID.
    -Pradnya

  • Using a "Sum" Calculated Field on a "Count" query column?

    Here's my query using the Query Report Builder:
    SELECT Col1, COUNT(Col1) AS Count_Column
    FROM Table
    GROUP BY Col1
    It generates a report that lists all the values of column
    "Col1" and how many times each value was used in Col1
    For instance, if Col1 contained the value 'A' 12 times, 'B' 6
    times, and 'C' 19 times, the report would generate this:
    A - 12
    B - 6
    C - 19
    What i need as a column footer is the total count of all the
    values, which in this case 12+6+19=37
    I am using a calculated field, setting the data type to
    Double, the calcuation to Sum, and the perform calculation on to
    'query.Count_Column'. Reset Field When is set to None.
    When I run the report, it doubles the last number in the
    report's Count column (19) and displays 38 on the page. I tested
    this with another column and it doubled the last number in the
    report as well.
    How can I get it to properly Sum my Count_Column?

    Hi,
    You need to check note 208366.1 which explains why totals can be blank. Without knowing the detail of you decode function it is hard to say what needs to be changed. Try putting a sum in front of the decode e.g.
    sum(decode(period, 'Jan period', value, 0))
    Hope that helps,
    Rod West

Maybe you are looking for

  • HP smart web printing is incompatible with Firefox 7.0.1

    HP smart web printing is incompatible with Firefox 7.0.1 Product name and model number: HP PHotosmart X7280 all in one printer OS : Windows seven 32 bit system

  • Not able to download updates on client after migration Win2012 to Win2012 R2

    Recently we Migrated WSUS from Windows Server 2012 to Windows Server 2012 R2. Refer for detailed steps: http://ininformationtechnologyworld.blogspot.in/2014/02/wsus-migration-from-windows-server-2012.html Now we realized that clients are not able to

  • [Newbie] Need to install .jar on the client or not ?

    Hello, I have MS SQLServer 7.0 with Weblogic driver on my W2000 Server. I try to access SQLServer from another machine. Do I need to install some .jar on the client ? Thanx. Sorry for this stupid question... :)) Johann

  • "Open with..." displays n times the same lot of applications

    Hi, Right-Click in a document file, Select to watch the list of available applications, ba-da-boom: I have four times the same list of available applications! Say - if the item is a html file - I get Firefox four times (and TextEdit four times and...

  • Lower Margins

    Using Windows 7 for my operating system, and Adobe Reader X (10.1.2) the item I'm trying to print appears correctly, but it doesn't print the bottom line, is there a way to adjust the lower margin?