Sum of a formula

Hi,
I have a formula, @Sum_NonComm_5_POS_BOM, in my Group 5 Footer
// Sum_NonComm_5_POS_BOM
whileprintingrecords;
global numbervar Sum_NonComm_3_Inv;
global numbervar Sum_NonComm_5_POS;
global numbervar Sum_NonComm_5_POS_BOM;
if {@Flag_POS_Non_Comm}
then Sum_NonComm_5_POS_BOM := Sum_NonComm_5_POS
else Sum_NonComm_5_POS_BOM := Sum_NonComm_5_POS + {Commission.POS_FI_NETTO_GES};
Sum_NonComm_3_Inv := Sum_NonComm_3_Inv + Sum_NonComm_5_POS_BOM;
Sum_NonComm_5_POS_BOM;
I also have another formula, @CommType_5_POS_BOM_Rate, in Group 5 Footer, which is calculated elsewhere, so very simple.
// CommType_5_POS_BOM_Rate
whileprintingrecords;
global numbervar CommRatePOS;
CommRatePOS;
In Group 3 Footer, I need to create a formula that sums @Sum_NonComm_5_POS_BOM only where @CommType_5_POS_BOM_Rate is not 0.
Syntax is eluding me.
Thank you,
Matt

Hi Matt,
Try this:
1) Create a Group Footer 5b section and suppress it
2) Create a formula with this code and place it on the new Group Footer 5b section:
whileprintingrecords;
numbervar subtotal;
If {@CommType_5_POS_BOM_Rate} <> 0 then
     subtotal := subtotal + {@Sum_NonComm_5_POS_BOM}
2) Create a reset formula and place it on the Group Header #3:
whileprintingrecords;
numbervar subtotal := 0;
3) Finally, create a Display formula that displays the subtotal on the Group Footer 3:
whileprintingrecords;
numbervar subtotal;
Hope this helps.
-Abhilash

Similar Messages

  • Summarizing Three (3) Formulas (When Using "Sum" Within Each Formula)

    I'm getting an error (i.e. 'This field cannot be summarized.") when
    trying to summarize three (3) formulas.  I figured out that it is
    probably because that there is a "Sum" in each formula.  I need totals
    only for specific officers (not all officers). Can someone tell me how
    to accomplish this ?  Thanks  ! ! !
    Formula #1
    NumberVar PeteTotal;
    PeteTotal := 0;
    If = "Pete"  And
       <> ["5001", "5030", "5031", "5032"] Then
       PeteTotal := Sum (, )
    Formula #2
    NumberVar MikeTotal;
    MikeTotal := 0;
    If = "Mike"  And
       <> ["5001", "5030", "5031", "5032"] Then
       MikeTotal := Sum (, )
    Formula #3
    NumberVar TonyTotal;
    TonyTotal := 0;
    If = "Tony"  And
       <> ["5001", "5030", "5031", "5032"] Then
       TonyTotal := Sum (, )
    Formula #4
    NumberVar AllTotals;
    AllTotals :=0;
    AllTotals := Sum(@PeteTotal, @MikeTotal, @TonyTotal)

    I got zeros . . .  below is the code  . . .  do you see anything wrong ?
    Formula #1
    NumberVar Total;
    Total := 0;
    Whilereadingrecords;
    If in ["Pete","Mike","Tony"]  And
       in ["5001", "5030", "5031", "5032"] Then
       Total :=
    Else
    0;
    Formula #2
    NumberVar GroupTotal;
    GroupTotal := 0;
    GroupTotal := Sum({@Formula #1});

  • Use of sums in other formulas

    Post Author: skootsu
    CA Forum: Formula
    Hello all.  I'm dealing with a huge report request that is to be output to excel.  It pulls from a inventory transaction table with tons of records.  I have  grouped by transaction type then summed and counted.  I need to take these sums and counts of each transaction type (3 types) then use these figures in other formulas.  My finished report will have 29 columns, 16 are formulas, 10 are based off these first 6 (sums&counts), the rest of the fields are flat data off the part records(like part #, description, last cost, productcode).  I'm thinking I can get all the data into one report (I was able to create a crosstab with the totals), however it will be huge and I only want to pull over the minimum needed data into the excel sheet.  Being new to Crystal Reports, I was wondering if a subreport is what might be what I need here or if I just some how can get the totals, like they appear in the crosstab, to come over so they can be used in new (summary) report?  I saw something about shared variable as well but my knowledge is limited to what I have picked up hands on.
    Any tips or hints are greatly appreciated.  This is the largest report I have had to create.  My past experience is with db2, query400 and what I would normally use to accomplish this task, rpg.  I have CR9& Oracle.

    Post Author: GraemeG
    CA Forum: Formula
    My past experience is with db2, query400 and what I would normally use to accomplish this task, rpg
    Ahhh, a man after my own heart!
    Just a quick warning, if you're pulling tons of data, doing loads of joins, making lots of clever calculations and summarising in all manner of ways, you may find that your report runs like a pig! The SQL Crystal generates is very clunky for starters and adding all the other bits will make developing, testing and running it quite tedious - particularly if you're new the the 'Crystal Way'. If I were you, I'd use a SQL client to figure out a cunning SQL statement that extracts and formats the data and does as many of the calculations and summaries as possible. Once you have this, use the 'Add command' bit in database expert to insert your own clean, quick and non-psychotic SQL code. This will give you something that looks like a file but contains your formatted data.
    I may be shouted down for suggesting this but by doing this, I reduced the run-time for a huge extract/calculate/export-to-excel report from 12 minutes down to 18 seconds and made a bunch of the other reports acceptable in the users eyes by reducing the run-speeds dramatically.
    Fair enough, the SQL statements are not simple but they run quickly and accurately and thats what counts. If you do decide to give this a try and need a hand, let me know.
    BTW, why wouldn't you use RPG to do this?

  • Best practice for creating a sum of a formula?

    What is the best way to create a sum on multiple groups from a formula or another sum?
    Sum ({IC_ADJS_JNL.QTY}, {IC_ITEM_MST.ALT_ITEMB}) * {NT_CONV_FCT.NET} - This is sitting in GF1, but I also need the sum of this on GF2.
    {NT_USED_DEM.USAGE_QTY} - {@RPK_LBS} - another example sitting in GF1 but needs its sum in GF2
    Hopefully I have explained this well enough. Thanks in advance for your help!

    You can create make use of global variable, the logic is similar to running total.
    What you do is:
    1. You initialize a global variable.
    Whileprintingrecords
    numbervar gcount::=0;
    2. You accumulate the variable at the section you want.
    Whileprintingrecords;
    numbervar gcount;
    gcount:=gcount + xxxx
    If you need certain condition, just use if statment like normal.
    3. To display the global varaible
    Whileprintingrecords;
    numbervar gcount;

  • How to display a Sum field for a formula column?

    Hi,
    I need to display a sum for a formula column at the end of report. for example: my formu_col=col_1-col_2
    col_1 col_2 formu_col
    3 1 2
    6 5 1
    total:sum(col_1) sum(col_2) sum(formu_col)
    now i have sum(col_1) and sum(col_2), but i don't have sum(formu_col)
    thanks

    Hi
    You may add a summary column in the same data group that you have sum(col_1) and sum(col_2). In that properties of the new column point the source as formu_col.
    Hope this helps.
    Fouwaaz

  • How to summarize the formula field for grand total

    Hi All
    Iam desinging a report in which iam facing a problem to summarize the formula field . This formula field contains sum calculation like
    formula name is @sales
    Sum ({@DTM200}, {@SaleMan})+Sum ({@DTM500}, {@SaleMan})+
    Sum ({@TM500}, {@SaleMan})+Sum ({@TM1000}, {@SaleMan})+
    Sum ({@HTM500}, {@SaleMan})+Sum ({@HTM1000}, {@SaleMan})+
    Sum ({@WM500}, {@SaleMan})+Sum ({@WM1000}, {@SaleMan})+
    Sum ({@CURD}, {@SaleMan})+Sum ({@Buttermilk}, {@SaleMan})+
    Sum ({@BULKWM}, {@SaleMan})+Sum ({@BULKTM}, {@SaleMan})
    the fields are summary fields and iam calculating all these fields to get the final result . Upto this it is working fine but finally i want to calculate the grand total of this formula '@sales' how should do this
    Thanks in advance

    Hi,
    If your formula name is @Sales you click the @Sales formula then Click Insert from Menu bar and click Summary.
    Then click Grand Total.
    Regards,
    Clint

  • Running Total - How to summarize a formula field?

    I'm sorry if this comes over as stupid but I have got myself quite messed up and am not 100% au fait with Crystal Reporting.
    The aim of my report is to calculate the costs of selected tests and to calculate a grand total of all tests at the end.
    I have created a group of  jobtests.TestTypeName
    Details
    1. testTypeName - to show Test Name that is being calcutaed - Database field
    2. Count ({jobTests.testTypeName}, {jobTests.testTypeName}) - to show number of tests of that type - this is a formula field
    3. Analysis1 - to show the cost of that test type - Database field
    4. {@CountTests/TestType} * {jobTests.AnalysisN1} - to show the number of tests per test type mulitplied by the cost of that test type - this is a formula field
    Report footer
    Count ({jobTests.testTypeName}) - to count the total number of tests
    MY PROBLEM - I need to see the sum of 4, this would be my grand total
    Trying to run the Running Total I can't get it to Summarize the field 4 because it is a formula field.
    What can I do?
    Thanks.

    You can't do a SUM on a formula that uses another aggregate function.  However, for both 4 and your grand total, you just need to SUM() (with ",{jobTests.testTypeName}" for the #4 calc), as the database field will be the cost for each test in each record.
    HTH,
    Carl

  • New to Crystal reports and need help with formula

    Post Author: dausa
    CA Forum: Formula
    I will try to keep this short and sweet.
    Data comes from excel sheet and I am doing a outter left join.
    The need: IF the status is S or N, then i want it to sum the qty required for each part number.
    my formula looks like this;  If ({WIP_ORDER.STATUS}) = 'C OR N' Then SUM ({WIP_ORDER.QUANTITY_REQUIRED}, {ORIGINAL_.PART NUMBER})
    thanks for any help
    dausa

    Post Author: Manuel de Kleine
    CA Forum: Formula
    Dausa,You could use a formula like below:IF  ({WIP_ORDER.STATUS}) IN &#91;'C','N'&#93;THEN 1ELSE 0Now, you can do a SUM on this formula.

  • Sort Group by a Formula

    Hello,
    I have a group called Part number with a few production jobs with in that group.  I also have a SPQ (Std Production Qty) for each Part number.  I have a formula called @AvgMQty that gets the average prodution qty. I have another formula called@diff that takes the ((SPQ-AvgMQty)/SPQ)*100 and I want to sort my report by this formula
    The Idea is to run the report for a given date range and show the Parts that have largest percent difference between the SPQ qty and what production is running.  I want to show the largest difference at the top of the report becasue the report can be very long.
    I've found a few other forums where people say this cannot be done becasue you can't sort a group using a "SUM" type of formula. 
    I would think what I'm doing is very common and someone knows how to do it!!!
    thanks for your help

    Give this a whirl - you might want to check it first by creating a new report, but rather than selecting tables, you'll want to use "Command" as the datasource once you've connected to your SQL Server.  As it is, this will select stuff between your previously used dates - but let's worry about that later.  For now, just check that the avg_prod_qty and sort_formula columns are giving you correct values...
    SELECT
    jomast.fpartno,
    jomast.fpartrev,
    inrtgc.fspq,
    joitem.fmqty,
    jomast.fddue_date,
    jomast.fjobno,
    jomast.fac,
    jomast.fstatus,
    jomast.fprodcl,
    averages.avg_prod_qty,
    (inrtgc.fspq - averages.avg_prod_qty)/inrtgc.fspq*100 as sort_formula
    FROM M2MData03.dbo.jomast jomast
    LEFT OUTER JOIN M2MData03.dbo.joitem joitem
         ON jomast.fjobno=joitem.fjobno
         AND jomast.fpartno=joitem.fpartno
         AND jomast.fpartrev=joitem.fpartrev
         AND jomast.fsono=joitem.fsono
    LEFT OUTER JOIN M2MData03.dbo.inrtgc inrtgc
         ON jomast.fpartno=inrtgc.fpartno
         AND jomast.fpartrev=inrtgc.fcpartrev
    left outer join --get the avg. production qty for a part number
         (select jomast.fpartno,
         avg(convert(float, joitem.fmqty)) as avg_prod_qty
         from jomast
         left outer join joitem
         ON jomast.fjobno=joitem.fjobno
         AND jomast.fpartno=joitem.fpartno
         AND jomast.fpartrev=joitem.fpartrev
         AND jomast.fsono=joitem.fsono
         group by jomast.fpartno) averages
    on averages.fpartno = jomast.fpartno
    WHERE (jomast.fddue_date>={ts '2008-06-01 00:00:00'}
    AND jomast.fddue_date<{ts '2009-06-01 00:00:01'})
    AND jomast.fac='Default'
    AND jomast.fjobno LIKE 'I%'
    AND jomast.fpartrev='NS'
    AND jomast.fstatus='CANCELLED'
    ORDER BY jomast.fprodcl, jomast.fpartno DESC

  • In iWork numbers 2.1 i have created monthly tables that end in sums of my daily numbers

    In iWork numbers 2.1 i have created monthly tables that end in sums of my daily numbers & i want to combine the sums for all months into a new table to allow me to get yearly sums.  When i try to copy monthly sums i get 'formula contains invalid reference.' How do i perform this function?

    DC,
    If you want to use Copy/Paste, you should use the Edit > Paste Values version. Or, you could simply add references in the Yearly table to the monthy tables.
    Jerry

  • Summing up the average field

    Post Author: jehanzeb
    CA Forum: Formula
    Dear all,
    how can we achive the following:
    I have two fields which are created using formula. My question is how can I get the grand total of those two fields. I have tried using the formula
    whileprintingrecords;numbervar myaverage;
    but this doesnt work.
    any ideas how to sum up the formula created fields?
    many thanks
    Regards

    Post Author: tsamara
    CA Forum: Formula
    Hi,
    First, are you able to sum up your fields individually at the grand total level?
    Then, if I understand your issue correctly, first do Sums of both fields and at the 'Grand Total' level and create a new Average formula.
    Good luck,
    Tony

  • Formula Help - Running Total vs ???

    Post Author: schilders
    CA Forum: Formula
    Good Morning All,
    I'm creating a report that contains a field called CDM Item.  This field indicates whether a particular order set was used for a given record.  Valid entries for this field are numeric 6 through 9.  I would like to create a formula that tells me the number of records that have a cdm item = 6, another formula that tells me the number of records that have a cdm item = 7 etc.  I need to summarize these formulas into pre-defined groups. 
    I was thinking a running total or a manual running total would be useful here.  However, I wanted to get some input from other formula gurus here.  Thanks, in advance, for your help.

    Post Author: yangster
    CA Forum: Formula
    You don't need to create a manual running total for what you are after.simply create 4 running totals ( 1 for each item number) using a running total with the evaluate formula of cdm =  6 (changed for each number)and resetting after whatever grouping you needthe other alternative you could implement if you have mutliple grouping and wanted subtotals on differing levels is to create a formula for each case such as@case_cdm6if cdm = 6 then 1 else 0then insert sum for each formula on all the differing group levels that way you only have to worry about maintaining one formula if the criteria changes

  • Using the SUMIF formula in Xcelsiuis

    Hi,
    I am trying to use the =sum(if( array formula in Xcelsius - but cant crack it. The formula seems to be working in offline mode and when i preview it. But when i launch the dashboard via a portal - the formula returns 0 value. Wanted to understand that is there something wrong that i am doing or does the formula not work in xcelsius ?
    Thanks !

    Hi Pat,
    "=SUM(B3-C3)" works.  Another option is "=B3-C3" No quotations.
    The bottom Right corner of A3 has a o click & drag down page.
    Alternatively click A3 then the position down the page you would like to end the formula, then got to Insert, Fill, Fill Down.  NB I have set up a shortcut for it.
    Enjoy
    Hope this helps

  • Can u use formulas across sheets?

    sorry if this is an obvious question, but i'm new to spreadsheets, so any guidance would be helpful.
    is it possible to, say, select cells from two sheets and have their sum appear in a cell on a third sheet??
    if so, how does one do that? it's probably in the manual, but i have no idea where to look.
    thanks

    Yup, the SUM function on the third sheet looks like SUM(number, number). Enter "SUM(" in the formula editor then click on the cell where the first number is (you can click on Sheet 1 first in the Sheets window) then type a comma in the formula editor and click the cell with the second number. Enter a ")" in the editor and hit Enter. Done. Sounds more difficult than it is. Basically, just click whenever you need a cell reference, it'll type in the proper syntax for you. It'll look something like "Table 1 :: A2".

  • Custom Group using a formula

    I need to count records like -
    Formula A - "if {'Accounting Code 08 Value} < 1 then 0 else {?Date as Number} + {@Count Invoice #}
    "Date as Number" is just that" and
    "@Count Invoice" is "WhilePrintingRecords; NumberVar InvoiceCount:= InvoiceCount + 1"
    But I need to create a  Group so I can sum data by Formula A, currently it is not a selection in group expert even though it is on the report.  Any ideas???
    THANKS

    Hi Bill
    Based on what field you want to create a custom group is not clear.  If you want to create a group based on your {Accounting Code 08 Value} then you will have to write a formula and insert the formula as group and go in group options and select the specified order.
    Formula @Group 
    If {Accounting Code 08 Value} >= 1 and {Accounting Code 08 Value} <= 100
    Then "group 1"
    Else
    If {Accounting Code 08 Value} >= 101 and {Accounting Code 08 Value} <= 200
    Then "group 2"
    Else
    If {Accounting Code 08 Value} >= 201 and {Accounting Code 08 Value} <= 300
    Then "group 3"
    Else
    "Group Others"
    This will create group1,group2,group3 and Group Others groups.
    Thanks,
    Sastry

Maybe you are looking for

  • HP Laserjet 2100TN - how to add IP printer in Snow Leopard

    I am not a very technical person, so this was quite an ordeal for me.  I was very frustrated by the process and almost gave up.  I am glad that I did not I just upgraded to Snow Leopard and after many hours of reading blogs and instructions etc. I fi

  • Imac g4 vga adapter (mirroring on different monitor)

    Hi, I am wondering what it means to mirror an imac g4. I am going to get a vga adapter ounce I get the imac and use a second 19" monitor. Also, what is the vga display output resolution with it. Thanks

  • UDF Value not showing in SQL

    Dear Experts... Here is a strange situation in my DB. I have some UDF on A/P Invoice for TAX details print preview. UDF Values are properly showing in SAP but not in SQL in same table, Same document they are blank in SQL. I can't understand why SQL d

  • Logical port could not be determined

    I try to send a WS RM Message from XI server to ABAP system. I get error :" Error while determining the logical port" Please suggest where is entry for logical port?

  • Email form with checkboxes

    Hi All, I have a form with checkboxes that I finally got to work partially. However, there is one problem. If you forget to check the checkbox, (Yes or No), you get the error Element is Undefined. If you check the checkbox there is no problem and the