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

Similar Messages

  • 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

  • Problem with the query of Sharepoint Calculated Fields

    Hello,
    I am developing an application in sharepoint 2013 foundation. but i have problems with a list, when executing a caml query on a calculated field. I try the solution of this blog
    http://sptalks.wordpress.com/2013/03/25/query-on-calculated-field-problem
    but i got no result
    attentive to any comments
    thanks

    Hello,
    This is my CAML Query
    <View>
    <ViewFields>
    <FieldRef Name="ID" />
    <FieldRef Name="PermMask" />
    <FieldRef Name="FSObjType" />
    <FieldRef Name="Nombre" AutoHyperLink="TRUE" />
    <FieldRef Name="Apellidos" AutoHyperLink="TRUE" />
    <FieldRef Name="Cargo" /><FieldRef Name="Edad" />
    <FieldRef Name="Compa_x00f1_ia" />
    <FieldRef Name="Created" />
    </ViewFields>
    <Query>
    <GroupBy Collapse="TRUE" GroupLimit="30">
    <FieldRef Name="Compa_x00f1_ia" />
    <FieldRef Name="Edad" />
    </GroupBy>
    <OrderBy>
    <FieldRef Name="ID" />
    </OrderBy>
    <Where>
    <Contains>
    <FieldRef Name="Ano" LookupId="FALSE" />
    <Value Type="Text">2014</Value>
    </Contains>
    </Where>
    </Query>
    </View>

  • Calculated field in a query

    Hi,
    To begin with I am just learning EJB and JAVA so please bear with me. I want to create a calculated field in a query from two fields in the table being queried, using SQL I would write the query like this:
    SELECT ledgerdate, description, quantity, unitprice, [quantity*unitprice] FROM ledger
    I have created a class called ViewLedger to contain my results, it has the following elements:
    DATE ledgerdate,
    STRING description,
    INTEGER quantity,
    BIGDECIMAL unitprice,
    BIGDECIMAL amount
    The query that I have been attempting that fails is:
    SELECT NEW ViewLedger(l.ledgerdate, l.description, l.quantity, l.unitprice, l.quantity*l.unitprice) FROM Ledger l
    The error says that there is an unexpected * in the query
    The following do not work either:
    SELECT NEW ViewLedger(l.ledgerdate, l.description, l.quantity, l.unitprice, (l.quantity*l.unitprice)) FROM Ledger l
    The error says there is an unexpected ( in the query.
    SELECT NEW ViewLedger(l.ledgerdate, l.description, l.quantity, l.unitprice, [l.quantity*l.unitprice]) FROM Ledger l
    The error says there is an unexpected [ in the query.
    Any help would be greatly appreciated.
    Thanks.

    I don't think JPQL allows functions (*) in the SELECT clause.
    You can use a native SQL query as a workaround. If you are using EclipseLink or TopLink Essentials, you can also use a ReportQuery.
    You may also want to vote for the bug,
    [https://bugs.eclipse.org/bugs/show_bug.cgi?id=219814|https://bugs.eclipse.org/bugs/show_bug.cgi?id=219814]
    James : [http://www.eclipselink.org|http://www.eclipselink.org]

  • 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

  • Add calculated field (Query - SQ01)

    Hi to all,
    I would know how can i add a calculated field to a Query (SQ01) ?
    Can you give me an example of abap code to insert in CODING section ?
    thks

    Hi,
    My understanding about your question is you want to display the total for two standard fields in a table,
    1) Personalize the table and make true for the property Total.
    2) If you want to calculate both the column total,
    Add a MessageStyledText via personalziation to the page, and extend the controller
    and in the ProcessRequest
    Get the handle of the AM and then ur attributes VO Attributes and traverse through the VO rows and get the total of both the columns
    and set the value to the newly created MessageStyledText.
    Let me you want any sample code for the second step.
    Thanks.
    With Regards,
    Kali.
    OSSi.

  • Inner Query relating to calculated field in main query

    I have a query that has calculating fields in it.
    What I am trying to do is Create another inner SELECT query similar to the one above but using the FP_Qty_Required calculated field in the main query?
    Is this even possible?
    Thanks in advance
    Aaron

    Sorry.  I did that because it looked a mess when I pasted it in.
    SELECT        P.ItemNumber, P.DeliveryWeek, D.StartDate AS WC_Date, S.SumOfSchedule_Qty, P.Planned_Production_Qty, P.Actual_Production_Qty, D.StartDate,
                             CASE WHEN S.SumofPartPallet < 0 THEN 'PART PALLET' ELSE '' END AS PartPallet, S.FirstOfIntouchRef, S.Pallet_Qty,
    S.FirstOfTool_Number,
                             CAST(CASE WHEN S.SumOfSchedule_Qty > 0 THEN (S.SumOfSchedule_Qty - 1.0) / S.Pallet_Qty ELSE 0.00 END AS DECIMAL(18,
    2)) AS DecNoOfPallets,
                             CEILING(CAST(CASE WHEN S.SumOfSchedule_Qty > 0 THEN (S.SumOfSchedule_Qty - 1.0) / S.Pallet_Qty ELSE 0.00 END
    AS DECIMAL(18, 2))) AS QtyOfFullPallets,
                             CASE WHEN s.sumofpartpallet < 0 THEN s.sumofschedule_qty ELSE CEILING(CAST(CASE WHEN S.SumOfSchedule_Qty >
    0 THEN (S.SumOfSchedule_Qty - 1.0)
                             / S.Pallet_Qty ELSE 0.00 END AS DECIMAL(18, 2))) * s.pallet_qty END AS FP_Qty_Required,
                                 (SELECT        SUM(SumOfSchedule_Qty) AS Expr1
                                   FROM            dbo.SumOfSchedDelivery
    AS s2
                                   WHERE        (ItemNumber = S.ItemNumber)
    AND (DeliveryWeek <= S.DeliveryWeek)) AS Running_Sum,
    FROM            dbo.Production AS P INNER JOIN
                             dbo.SumOfSchedDelivery AS S ON P.ItemNumber = S.ItemNumber AND P.DeliveryWeek = S.DeliveryWeek INNER JOIN
                             barcoding.dbo.DeliveryWeeks AS D ON P.DeliveryWeek = D.DeliveryWeek INNER JOIN
                             dbo.TotalRequiredByItem AS T ON S.ItemNumber = T.ItemNumber
    The above works.  What I want to do next is after the Running_Sum to add another sub query similar to this:
    (SELECT        SUM(FP_Qty_Required) AS Expr2
                                   FROM            ???
                                   WHERE        (PD.ItemNumber = ItemNumber)
    AND (PD.DeliveryWeek >= DeliveryWeek)) AS Running_FullPallet
    FP_Qty_Required is a calculated field in the main query.

  • New Calculated field question. Complicated I think.

    I have managed to create this table from a MySQL database: http://ppbm5.com/DB-PPBM5.php
    The field 'Total' is a calculated field using this SQL query:
    $query_Recordset1  = 'SELECT *, `Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE  Off`) As Total, `CPU`*`Cores` As Phys_Cores FROM `Personal_data` WHERE 1  ORDER BY (`Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`)),  `Date & Time` ASC';
    So far, so good, but as you may have  noticed, there is a next field called 'Rel. Perf.' which only contains  blanks. And that is where my problems start.
    The table is sorted by 'Total' and the first record shows these figures and field names that are relevant for my question:
    Fields: 'Total'  'Disk I/O'  'MPEG2-DVD'   'H.264-BR'   'MPE On'   'MPE Off'
    Values:  131,        67,              21,                  37,              6,              64
    In addition, I use four 'weight' figures, let's say these are 0.27 , 0.30 ,  0.20 and 0.23 denoted as W1, W2, W3, W4.
    First step is to calculate four temp values, using a formula like this resulting in T1, T2, T3 and T4:
    T1 = W1 x  Total /Disk I/O; T2 =  W2 x Total/MPEG2-DVD ; T3 = W3 x Total/H.264-BR ; T4 = W4 x Total/(IFNULL(MPE On, MPE Off)
    Note that this only applies to the top record and here the SUM(T1, T2, T3, T4) results in 131, equal to the Total.
    The result of 100 x SUM(T1, T2, T3, T4)/ Total = 100 should be the 'Rel.Perf.' result for the top record.
    Now  is gets difficult. Let me call the records R1, R2, R3, ..., Rx. Now, in  the previous step we have established that the figure 100 should into  R1.
    For R2 the result of the 'Rel.Perf.' is 100 x SUM(T1 x Disk  I/O(2), T2 x MPEG2-DVD(2), T3 x (H.264-BR(2), T4 x (IFNULL(MPE on, MPE  Off)))/ Total(2)
    For R3 the result of the 'Rel.Perf.' is 100 x  SUM(T1 x Disk I/O(3), T2 x MPEG2-DVD(3), T3 x (H.264-BR(3), T4 x  (IFNULL(MPE on, MPE Off)))/ Total(3)
    etcetera for all the rest of the records in the table.
    A  complicating factor is that the reference point of the top machine  should remain fixed at 100, but when doing queries, the top machine may  not be in the query results, but all the query results for the Rel.Perf.  should be derived from these scores. Life would be infinitely easier if  one would be certain that the top machine is fixed, but that is not the  case.
    Sorry to make this such a long and complicated post, but  for those who have struggled through this long message, if you have any  suggestions on how to make this work, I would appreciate it.
    Thanks in advance.
    Harm, while non is intended.
    PS. I have been trying to generate a SQL query, using the following code:
    $query_Recordset1 = 'SELECT *, FORMAT(`Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`),0) As Total, FORMAT((54.661*`Disk I/O`+161.25*`MPEG2-DVD`+71.66666*`H264-BR`+645*IFNULL(`MPE On`,`MPE Off`))/129,1) As RPI,`CPU`*`Cores` As Phys_Cores FROM `Personal_data` WHERE 1 ORDER BY 54.661*`Disk I/O`+161.25*`MPEG2-DVD`+71.66666*`H264-BR`+645*IFNULL(`MPE On`,`MPE Off`), `Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`) ASC';
    For static work it is OK, but not when a new top performer submits his data.

    Hi William,
    Per my understanding that you want to count the number of the value in the field wait which is smaller then 15, right?
    I have tested on my local environment and that you can add the calculated field (Count) using the expression as below:
    =IIF(Fields!wait.Value<15,1,0)
    Insert an outside group row and then get the total count by using below expression:
    =SUM(Fields!Count.Value)
    Preview you will get the result like below:
    If your problem stil exists, please try to provide some sample data and the exprect count result you want.
    Any problem, please feel free to ask.
    Regards
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Problem with Math In Calculated Fields

    I am calculating a group incident rate for data returned from
    a query. The formula is Number of cases multiplied by 200000
    divided by number of hours worked. Cases in my report is the
    calculated field: calc.CaseSum (the sum of cases for the group)
    Hours is calc.SumHours (the sum of hours for the group). The actual
    values for these variables (for the first group are 48 and 29427171
    respectively. When I create the following calculated field called
    rate using the formula: (calc.CaseSum * 200000) / calc.SumHours,
    Cold Fusion Generates a Runtime Error:
    Invalid ColdFusion expression in report. If the expression is
    a string, ensure that it is within quotes. Error: (calc.CaseSum *
    200000) / calc.SumHours is not a valid ColdFusion expression.
    If I use the constant value "29427171" as the divisor, the
    report works albeit only for the first group. Any ideas; is this a
    bug, or am I misusing the product?
    Addition: I forgot to mention I am using CF8. Also this
    formula worked fine as a Report Total before I introduced grouping
    and modified the calculated fields to reset on the change of a
    group.

    Sorry, I've been on another project for awhile. This problem
    will certainly be a "show stopper" for me if I cannot resolve it.
    As I mentioned in my original post, I used a constant in the
    formula in lieu of the variable and the calculation worked. This
    would suggest that CF does not have a problem with a large number.
    In spite of that reasoning, I tried Tony's suggested (thanks
    by the way!) with the identical outcome, only difference is the new
    formula is displayed in the error message.
    Tony, you also suggested that I set the variables using
    CFSET... How would I do this within the report writer environment.
    I had tried a similar approach: to perform half the calculation
    i.e. that within the parenthesis, and assign that value to a
    separate "calculated field: and then perform the rest of the
    calculation on that variable with the same outcome.
    I think that I may be dealing with a CF bug here, I'd like to
    find a workaround... I've noticed that CF8 has a new patch, perhaps
    after I apply it, I may be able to get this thing to work. I'm on
    another project right now so it will be a few days before I can
    test this theory, I report the result.
    Should this fail, and no one can come up with a workaround, I
    will report this to Adobe.

  • Running total of calculated field in pivot

    VERSION: ORACLE 11
    TABLE:
    create table chart_detail (
    DIS        NUMBER,
    BLD_MO VARCHAR2(7),
    BLD        NUMBER(10),
    RPLC      NUMBER(10));DATA:
    insert into chart_detail values (60,'2011-03',0,2);
    insert into chart_detail values (150,'2011-04',10572,0);
    insert into chart_detail values (120,'2011-04',26449,5);
    insert into chart_detail values (30,'2011-04',0,1);
    insert into chart_detail values (60,'2011-04',0,7);
    insert into chart_detail values (90,'2011-04',0,9);
    insert into chart_detail values (120,'2011-05',5714,0);
    insert into chart_detail values (90,'2011-05',24557,1);
    insert into chart_detail values (60,'2011-05',0,4);
    insert into chart_detail values (30,'2011-05',0,0);
    COMMIT;EXPECTED RESULTS:
         2011-04                    2011-05               
    DIS     RPLC     BLD     TBLD     IPTV     RPLC     BLD     TBLD     IPTV
    30     1     0     37021     0.03     0     0     30271     0.00
    60     7     0     37021     0.22     4     0     30271     0.13
    90     9     0     37021     0.46     1     24557     30271     0.17
    120     5     26449     37021     0.59     0     5714     5714     0.17
    150     0     10572     10572     0.59               0     
    180               0                    0     
    TOTAL     22     37021               5     30271          PROBLEM: I need to have a running total of IPTV like in the above example. I can get the IPTV for each DIS/bld_mo but I don't know how to get the running total of it. In the script below I just used an example where I tried summing the IPTV like was done for build. I know it can't be done that way because IPTV is a calculated field in the query but if I substitute "APR_IPTV" with the formula for IPTV I get an error that window functions aren't allowed here. I do not know a way around this. I commented out the bad piece of code.
    PROBLEM SCRIPT:
    WITH  pivot_results  AS
      SELECT    dis
      ,    NVL (apr11_rep,  0)  AS apr11_rep
      ,    NVL (apr11_bld,   0)  AS apr11_bld
      ,    NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS apr11_tbld
    ,      DECODE(NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(apr11_rep, 0)*1000/ NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS apr11_iptv               
    ,      NVL ( SUM (apr11_iptv)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS apr11_tiptv  
      ,    NVL (may11_rep,  0)  AS may11_rep
      ,    NVL (may11_bld,   0)  AS may11_bld
      ,    NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS may11_tbld
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_iptv
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_tiptv               
      FROM     chart_detail
      PIVOT     (  MAX (rplc)  AS rep
              ,  MAX (bld)  AS bld
              FOR  bld_mo   IN ( '2011-04'  AS apr11
                                             , '2011-05'  AS may11
    SELECT    CASE
            WHEN  GROUPING (dis) = 0
            THEN  TO_CHAR (dis)
            ELSE  'Total'
        END      AS dis
    ,    SUM (apr11_rep)  AS apr11_rep
    ,    SUM (apr11_bld)  AS apr11_bld
    ,    SUM (apr11_tbld) AS apr11_tbld
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (apr11_iptv)
        END      AS apr11_iptv
    ,    SUM (apr11_tiptv) AS apr11_tiptv
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (apr11_tpiptv)
        END      AS apr11_tiptv
    ,    SUM (may11_rep)  AS may11_rep
    ,    SUM (may11_bld)  AS may11_bld
    ,    SUM (may11_tbld) AS may11_tbld
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (may11_iptv)
        END      AS may11_iptv   
    FROM    pivot_results
    GROUP BY  ROLLUP (dis)
    ORDER BY  pivot_results.dis
    ;Thank you,

    Hi,
    So you know how to compute iptv for an individual row; the problem now is that you want to get a running total of iptv; is that it?
    The problem there is that computing iptv requires an analytic function, and analytic functions can't be nested. To get the results of nesting f (g (x)), where f and g are analytic funtions, you have to compute g in a sub-query, and then use the results as the argument to f in a super-query.
    Here's how to apply that to your situation:
    WITH  pivot_results  AS
         SELECT    dis
    -- April, 2011
           ,           NVL (apr11_rep,   0)  AS apr11_rep
           ,           NVL (apr11_bld,   0)  AS apr11_bld
           ,           NVL ( SUM (apr11_bld)
                                       OVER (ORDER BY dis DESC)
                          , 0
                          )               AS apr11_tbld
         ,      NVL ( 1000 * apr11_rep
                              / NULLIF ( SUM (apr11_bld) OVER (ORDER BY dis DESC)
                                          , 0
                   , 0
                   )               AS apr11_iptv
    -- May, 2011
           ,           NVL (may11_rep,   0)  AS may11_rep
           ,           NVL (may11_bld,   0)  AS may11_bld
           ,           NVL ( SUM (may11_bld)
                                       OVER (ORDER BY dis DESC)
                          , 0
                          )               AS may11_tbld
         ,      NVL ( 1000 * may11_rep
                              / NULLIF ( SUM (may11_bld) OVER (ORDER BY dis DESC)
                                          , 0
                   , 0
                   )               AS may11_iptv
           FROM     chart_detail
           PIVOT    (    MAX (rplc)  AS rep
                    ,    MAX (bld)   AS bld
                    FOR  bld_mo   IN ( '2011-04'  AS apr11
                                      , '2011-05'  AS may11
    SELECT    CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  TO_CHAR (dis)
                  ELSE  'Total'
               END      AS dis
    -- April 2011
    ,           SUM (apr11_rep)  AS apr11_rep
    ,           SUM (apr11_bld)  AS apr11_bld
    ,           SUM (apr11_tbld) AS apr11_tbld
    ,           CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  ROUND ( SUM (SUM (apr11_iptv))
                                          OVER (ORDER BY  dis)
                      , 2
               END      AS apr11_iptv
    -- May 2011
    ,           SUM (may11_rep)  AS may11_rep
    ,           SUM (may11_bld)  AS may11_bld
    ,           SUM (may11_tbld) AS may11_tbld
    ,           CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  ROUND ( SUM (SUM (may11_iptv))
                                          OVER (ORDER BY  dis)
                      , 2
               END      AS may11_iptv
    FROM      pivot_results
    GROUP BY  ROLLUP (dis)
    ORDER BY  pivot_results.dis
    ;Output:
          APR11  APR11   APR11  APR11 MAY11  MAY11   MAY11  MAY11
    DIS    _REP   _BLD   _TBLD  _IPTV  _REP   _BLD   _TBLD  _IPTV
    30        1      0   37021    .03     0      0   30271    .00
    60        7      0   37021    .22     4      0   30271    .13
    90        9      0   37021    .46     1  24557   30271    .17
    120       5  26449   37021    .59     0   5714    5714    .17
    150       0  10572   10572    .59     0      0       0    .17
    Total    22  37021  158656            5  30271   96527As you can see, this is not quite what you wanted on the row where dis='150'. You asked for NULLS in the may11_rep, may11_bld and may11_iptv columns. You can get those results if you need them; just explain the rules that govern whether to display the values and when to display NULL.
    The way you posted the sample data and results, and the quantity of sample data were all excellent; it really helped me find a solution. Thanks.
    It would have also helped it you had explained how iptv is computed. Basically, iptv = 1000 * rep / tbld, right?
    It looks like most of this code:
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_iptvwas a way of avoiding divide by 0 errors; it would have been helpful if you had explained that.

  • Answers - would like to use calculated field's name, not expression

    Hi Everyone,
    I'am trying to make several calculated fields in a single query in Answers. Each field references the previous one, and the expression of the first one is already 5 rows long.
    Now I reference it in the second calculated field by using "Edit Formula" -> "Column" -> 'Colum name'.
    My problem is, that it puts the expression of the previous field, not it's name. I have to use it for almost 10 times in this single expression, so -although it works fine- it is totally unreadable, and very hard to debug for example.
    And after all, I should use this field again, in several next calculated fields.
    Does anyobody have an idea, how to make calculated fields having only the name of referenced other fields in it?
    The repo is set for ad hoc reporting also, so using session variables which need to be set in Administrator Tool, is not an option.
    Thanks for help in advance.
    Tom
    Message was edited by:
    user608765

    Hi Venkat,
    thanks for the response. It would work, no doubt, in this special case, the problem is, that users use the repo for ad-hoc reporting aswell (and they don't have access to repo administration of course), so one can count on it, that there would be a new request of this kind every day to change the repo with customized user variables. I would like to avoid this of course.
    Having the name of a referenced field in a new expression would be a simple solution. Is it possible, that it can't be done?
    Tom

  • SAP HANA calculation field

    Hello,
    I have a query on the new calculated field in SAP HANA. What is the usage of this field, what are the pre-requisites and potential case when it is recommended to use such fields? Do we need to have a calculative view to use the calcluated field or can it be used directly in ABAP code?
    Kindly let me know. We are in the process of code optimization for HANA.
    Best Regards,
    Mohit

    Hey Mohit,
    can you please give a bit more details, e.g. documentation about what you refer to as "the new calculated field in SAP HANA".
    Concerning the details of usage within HANA, i.e. whether you need a calculation view etc. you might have a look at the SAP Help (Introduction - SAP HANA SQL and System Views Reference - SAP Library)) or maybe directly in the HANA SQL reference (http://help.sap.de/hana/SAP_HANA_SQL_Script_Reference_en.pdf).
    From my answer I think you can directly guess, that there's no way in directly accessing the calculated field from ABAP - except of course if you access it using native SQL (ADBC or EXEC SQL).
    For code optimization in SAP HANA (from an ABAP developers perspective), you might want to have a look at our Open SAP course (ABAP Development for SAP HANA - Dr. Jasmin Gruschke and Jens Weiler) or in the documentation given in our "Get Started" Section of ABAP for SAP HANA namely ABAP for SAP HANA Reference Scenario and ABAP for SAP HANA Reference Scenario - AS ABAP 7.4 Support Packages.
    In case you need more HANA (less ABAP) related information for your question, you might additionally contact the HANA experts on SAP HANA Developer Center.
    Cheers,
    Jasmin

  • Inserting calculated fields in database queries

    I have just changed from using StarOffice version 7 to version 8.
    I am having difficulties in creating a calculated field in a query.
    Would anyone have some ideas for me to follow?
    Thanks - Dan

    1.  Order as a column name could be problematical as it might conflict with the SQL 'ORDER BY'.  Wrapping it in square brackets should cater for this.
    2.  You are missing some spaces.  
    3.  The use of the arithmetical + operator could be problematical with dates as the string expressions, which might be interpreted as arithmetical expressions.  The + operator is used rather than the ampersand concatenation operator to suppress
    Nulls, but that's not the case here.  
    4.  As you are only returning columns from one table you do not need to qualify the column names with the table name.  
    5.  Defining a range as on or later than the start date and before the day following the end date is more reliable as it allows for rows with date/time values on the last day of the range with a non-zero time of day element, something you cannot rule out
    with complete confidence unless you have taken specific steps in the table definition to disallow such values.
    So taking these points into account:
    strSQL6 = _
            "SELECT [Order], [OperWorkCenter], [Created on], " & _
            "[Actfinish date]," [Actfinish date]-[Created on] AS Delta " & _
            "FROM [WOMP Work Orders] " & _
            "WHERE [Created on] >= #" & FStartDate$ & "# " & _
             "AND [Created on] < #" & FEndDate$  & "# + 1"
    The FStartDate$ and FEndDate$ values must of course be in US short date format or an otherwise internationally unambiguous format such as the
    ISO standard date format of YYYY-MM-DD.
    Ken Sheridan, Stafford, England

  • What is a Calculated Field?

    Hi,
    I have an assignment which requires me to use a 'calculated field' in a query.
    Despite searching and looking in the books I have, I find no reference to the term.
    I'm guessing that it may mean something like:-
    WHERE CUSTOMER.CustomerID > 3 * min_orders
    The " 3 * " being a calculated field.
    Is this it? Or does it mean something else?
    Many thanks for any assistance.

    This question has nothing to do with the Installation forum....
    Post this to the appropriate forum (Forms , Discoverer forum ..to name some).
    Greetings...
    Sim

  • How to insert calculated field in SQ01

    I would like to add a calculated field in a query but can´t find any documentation.
    the specific problem is that I would like to add a basic mark up on some costs.
    can anyone help
    Keel

    Unless you need some very complex calculations, this may be done in SQ01. The process is not very intuitive though.
    1) In SQ01, open the query in the change mode. Go to the Field Selection screen (the 3rd one).
    2) If you need to use an existing field in calculation, give that field a "short name" (if you don't see the Short Name column, go to the menu Edit -> Short Names -> Switch On).
    3) Now create a new field. Go to the menu Edit -> Local Field -> Create. Give the field some name and descrption. Choose the properties that you need and enter the Calculation Formula using the short name from step 2 (e.g. COST * 1.10 to add 10% to the COST field).
    You can also add conditions and use more than one existing field. I always use those local fields to display the invoice value, because NETWR is always a positive number, but it should be displayed as negative for cancellations and credits.

Maybe you are looking for

  • Vendor wise sales report

    Hi Expert, Client requirement is like this Client procure "Article-ABC"from different vendors like Vendor 1, vendor 2, Vendor 3 and client do the sale to his customers now client want to know how much "Article-ABC" sold from with respect to vendor1,

  • Total no. of lines in JTextPane document and Increment them on "ENTER" key

    hello, I wanted to know the total number of lines that a document has. I.e for example when I open a .java into my JTextPane, I wanted to know the total no. of lines the file has and I wanted to increment them when I press the enter key. 2. Even it i

  • Try/catch code

    I have a question concerning java try-catch blocks. Is there a way for java to catch multiple exceptions in one block? For e.g. by enclosing the try/catch block within a loop? Is this possible? Thanks. Liza

  • Question on icloud and creating users

    I have noticed that my Macbook Pro will create its own user.  I immediately deleted this user since I didn't create it and thought it was taken care of.  Well, I turned on my computer again today and the user was created again, without my consent.  M

  • Can't see movie playlists in ATV section of iTunes

    I created a playlist of home movies in iTunes 8.2.1, using ATV files made with QT Pro. The playlist has a music icon. When I look in the ATV movie section on iTunes, I don't see the playlist as a selectable item for syncing (I'm using custom sync for