Sum formula by Group

Hello, I'm having a problem getting this summary to work. I have a group {PRDT.PREndDate} which is a date field and I have a sum formula that adds two fields. The problem is when I try to limit the sum to the {PRDT.PREndDate}  group I get an error "There must be a group that matches this field". I'm sure I'm missing something in my formula.
here's the formula:
sum({@EC1}, {PRDT.PREndDate})+
sum({@EC2}, {PRDT.PREndDate})
Thanks,
Gerald

My Group Header #2 is {PRDT.PREndDate} , does it matter that the field type is Date? Here are the other formulas:
@EC1
if {PRDT.EDLType}='E' and {?EC1}={PRDT.EDLCode} then
     -({PRDT.Amount})
else
    0
@EC2
if {PRDT.EDLType}='E' and {?EC2}={PRDT.EDLCode} then
     -({PRDT.Amount})
else
    0
Edited by: akamax_power on Aug 5, 2009 6:51 PM
Edited by: akamax_power on Aug 5, 2009 6:53 PM

Similar Messages

  • Formula by Group and based on a condition

    Post Author: Ravi
    CA Forum: Formula
    Hi All,
    I need to create a formula by Group and based on a condition. Below the syntax is wrong but this is the calculation that I am after!
    Sum({@Test_Dollars}, ) where {Customer Number} = 12
    Basically, I need to display/calculate the 2nd column in the sample report/output.
                      All Customers                    Only  Customer 12
    Company    $500                                  $125    
        Zone A  $200                                   $50
       Zone B   $300                                   $75
    Thanks in advance,
    Ravi

    Post Author: Jagan
    CA Forum: Formula
    I think you should be able to get this from a running total with a formula to only include records where the customer number - 12

  • Web Service Connection on fresh SUM formula is zero

    I am using Xcelsius SP1.  I have a field in the spreadsheet that has the formula "=SUM(H12:H16)".  I am using a Web Service Connection to refresh the data.  Following a refresh from the web service connection the field with the SUM formula is 0.  I have discovered that ff the values in SUM range (in my case H12:H16) are identical to the refrehsed data then the formulas results willl be 0.  If one of the sum values is different from the original values then the sum formula works.  Is this a bug? Is there a work around?

    I had a problem with the data format after getting number-values from my web-service, because every number-value I got was not a number - it was a string.
    so I had to convert all the data in Excel from string to number values. after that everything works fine for me.
    you could try that out....

  • Sum based on group by and one condition

    I have a tableof following structure
    Group SubGroup sequence length 
    A         x               1            10
    A         X        
        2            20
    A         X               2            30
    A         X               3            50 
    B         Y               4  30
    B         Y               5            40
    I needa new column with a sum of lengths grouping Group,sub group and sequence but the condition is sum should be calculated based on the sequence of each row.Sum is sum of lengths where sequence is greater than the current row sequence number and grouping
    group nad sub group
    following is the output i am looking for
    Group SubGroup sequence length   Sum
    A         x               1            10          100(Sum of all the lengths where sesquence > current rows sequence
                                                             and group by group,sub
    group and sequnce) 
    A         X               2            20          50
    A         X   3 30 NULL
    B         Y               4  40 50
    B         Y      5 50 NULL

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. 
    And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I have a table of following structure <<
    Your posting is crap! Did you know that GROUP and SEQUENCE are reserved words in SQL? Did you really want to use a CREATE SEQUENCE? Did you know a table has a name and key?? That having a separate “<something>_sub_group” column is so bad a design flaw
    it has a name (attribute splitting)? That “<something>_length” cannot exist without being the length of something in particular? 
    CREATE TABLE Rude_Postings
    (rudeness_grp CHAR(2) NOT NULL
     CHECK (rudeness_grp LIKE '[A-Z][A-Z]'),
     foobar_seq INTEGER NOT NULL
     CHECK (foobar_seq > 0),
     PRIMARY KEY (rudeness_grp, foobar_seq),
     foobar_length INTEGER NOT NULL
     CHECK (foobar_length > 0)
    The foobar_seq simply looks wrong. It was not unique, so it could not be a sequence by definition. I will guess that it is unique within a rudeness_grp. 
    INSERT INTO Rude_Postings
    VALUES
    ('AX', 1, 10),
    ('AX', 2, 20),
    ('AX', 3  30),
    ('AX', 4,  50),
    ('BY', 1 , 30),
    ('BY', 2 , 40);
    >> I need a new column with a sum of lengths grouping Group,sub group and sequence but the condition is sum should be calculated based on the sequence of each row. Sum [sic: SUM is a reserved word!] is sum of lengths where sequence is greater than the
    current row [sic: tables are sets not files, so there is no ordering and no concept of a current row] sequence number and grouping group and sub group << 
    Here is my guess:
    SELECT rudeness_grp, foobar_seq, foobar_length 
       SUM( foobar_length) 
           OVER (PARTITION BY  rudeness_grp 
                   ORDER BY  foobar_seq DESC
                   ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
         AS foobar_length_running_tot
      FROM Rude_Postings;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Sum formula not calculating sum accurately

    Hie All,
    In my Webi report, I've included a sum formula (Sum[actual hours]) for both rows and columns. However, the total is inaccurate for some rows/columns. Any idea why this could happen and how to resolve the issue? Thanks.

    Hi Jeewan,
    You can try these but i'm not sure it will work:
    1. Try merge dimension on common objects.
    2. Try sum(sum([actual hours]))
    3. Instead of using formula you can use the sum function available in "Analysis -> Function -> Σ Sum"
    4. It can be due to the projection used at universe level for this you have to access the universe and check.
    5. Try dragging some compatible objects in object browser it might happens some times that data will not come correctly.
    6. last one (hit and try) check the filters once.
    Hope this helps,
    Thanks,
    Shardendu Pandey

  • Sum formula doesn't change when add row

    This question is about Numbers.  I have a column of numbers with a sum cell at the bottom of the column.  Sometimes I need to insert a row at the very bottom of the column, just above the cell with the Sum formula.  I then need to tweak the sum formula to include that added row; however, if I add a row in the middle of the column, the sum formula automatically changes to include that added row. 

    Hi c,
    Numbers will automatically adjust the formula if all body cells above the added cell have the same formula, or if the added cell is within the range specified in the formula.
    In the middle of the column, the second is true. At the end of the column, the added cell is outside the range specifired in your formula, and there is at least one regular cell above that does not contain the same formula.
    Use one or more header rows at the top of the table for your labels. Use a Footer row to hold the SUM formula. Place the SUM formula in the Footer row, using =SUM(B) for example to SUM the values in all of the body cells in column B.
    Regards,
    Barry

  • Sum formula for tables

    I have made the switch from MS to MAC and word to pages and so far am as happy as can be!
    Then, I go to add a sum formula to a list of numbers in a table column so that I can have a total at the bottom of the column.....AND, I can't find a way to do this in pages.
    I've searched this forum but can't find anything, so I am sure it is me and not pages that has the problem. Surely pages wouldn't leave out the ability to sum a column of numbers?

    A table is not a spreadsheet &, currently, iWork does not have a spreadsheet application. I do believe CalcService by Devon Technologies can do some basic calculations in a spreadsheet.

  • Formula help - Group totals for more than one date range

    Post Author: melcaylor
    CA Forum: Formula
    I need to show in 3 columns
    inside of a grouping that totals an amount field based on a date
    range that amount was posted.  So for example:
    Billy Bob in the state of MA made $5.5m total, $800k in the last 21 days, $400k in the last 14 days and $150k in
    the last 7 days.
    I assume this is possible but I
    just donu2019t know what type of formula to write to make it work.  For this
    example, there are 2 tables u2013 user table and $$ table.  The User table has
    the user name, the $$ table has the pay date and the amount. 

    Post Author: SKodidine
    CA Forum: Formula
    You only need simple formulae in Running Totals to accomplish this.
    1.  Group by Name
    2.  Create the following Running Totals:
    2.1 A running total to sum the pay amount for all records, and resets on 'Change of Group' of Name.
    2.2 A running total to sum the pay amount and for 'Evaluate' click on the radio button next to 'Use a formula' and then click on X-2 button next to it.
    In the formula workshop window type a formula such as: {table.payment_date} in (currentdate - 21) to currentdate;
    For 'Reset' click on the radio button next to 'On change of group' and pick the group name.
    2.3 Create another running total just as in step 2.2 above but change the formula to: {table.payment_date} in (currentdate - 14) to currentdate;
    2.4 Create the last running total just as in step 2.2 above but change the formula to: {table.payment_date} in (currentdate - 7) to currentdate;
    Hide the details section and in the group footer place text boxes with appropriate text and insert these running totals to give you the numbers you want.
    The only issue I see with this is if a person was paid yesterday a sum of $25, then it will show $25 for total, last 7days, last 14days and also for last 21days.  At first look it might be mistaken for $75.

  • Sum and Average Group Wage instead of Details Wage

    I have a subreport where I have included all of our employment records and grouped it by employee ID. In the Group Footer, to show the latest employment record I used the Max(Start Date) and I have also placed the Hourly Wage field here which shows the appropriate Wage for the Max Date. But I can't seem to use the Sum or Average Summary because it Sums and Averages All Wages in the Details report vs. only the latest record.
    So, how do I Sum/Average the wages for only the last employment record Or how do I create the report to show only the Last Employment Record?
    I'm using Crystal XI. Any help will be greatly appreciated.
    Thanks

    Place the fields in group header instead of placing in details section using maximum() function. Now got to report>record sort expert>add start date field-->select descending order.
    Now the report shows latest date entries for each group.
    If you want to calcualte the sum then use mannual running totals like
    create a formula like
    @sum:
    whileprintingrecords;
    numbervar i;
    i:=i+{field}
    Now place this in group header and supress
    create another formula like
    @Total:
    whileprintingrecords;
    numbervar i;
    place this in report footer which gives grand total.
    Regards,
    Raghavendra

  • CRXI: Formula To Loop Through Formulas in Group

    Post Author: Mile
    CA Forum: Formula
    I have a hierarchy of groups allowing the drilldown of data. Due to a flaw in database design, there is no real join between two tables and I've improvised as best I can. The problem is that on one of my items, there can be as many as thirteen products attributed to it. This produces thirteen records for the one item, meaning that summing on the amount field will be thirteen times the actual amount. But, as I said, each product may have a different number of products attributed to it, meaning it could be five times the amount, seven times, the amount, etc.
    I've been able to make a summary at the item level whereby all I need to do is a formula that divides the sum by the count of products to get the actual value. When I move to the next group level up, I find that it can't mathematically be done to divide the summed amount because one item in the group may have two products (therefore two records) and another ten products.
    What I'm wondering is whether there is a way, using a formula, that can loop through all the items in a group and add the summary field.
    i.e.
    ITEM1 - PROD1 - $5
    ITEM1 - PROD2 - $5
    ITEM2 - PROD1 - $7
    ITEM2 - PROD2 - $7
    ITEM2 - PROD3 - $7
    ITEM2 - PROD4 - $7
    ITEM2 - PROD5 - $7
    ITEM1 would summarise to $5, once I've divided it by two. ITEM2 would summarise to $7, once I've divided it by five.
    So, ideally, I would loop through a group above the item level, adding the summaries, ending with $12.
    Can this be done?

    Post Author: synapsevampire
    CA Forum: Formula
    Your difficulty is termed record or row inflation.
    If you want a summary at the group level, group by the item field and use a maximum instead of a sum.
    maximum({table.value},{table.item})
    Then to get a grand total, create a formula such as the following for the gropup footer:
    whileprintingrecords;numbervar MyTotal;MyTotal := MyTotal + {table.value}
    Now you can display the grand total in a subsequent secion using:
    whileprintingrecords;numbervar MyTotal
    -k

  • Display the sum of a group

    Hi,
    I what i  want do is simple but can't find it anyway, I am just a beginner with crystal. My report displays a list of product group by product_group. I want to to display in the header of each group the sum of the product price included in that group of course.
    Example:
    Product Group--product price--
    Product group A -
    <Sum price>----
    10.00
    product A--5.00--
    product B--3.00--
    product C--2.00--
    Product group B--<sum price>--
    6.20
    product D--2.20--
    product E--4.00--
    I have tried the formula field and the running total field but I am probably doing it wrong . Either it gives the sum of all the articles or the only the price of the first article included in the group.

    A group-based formula should do the trick, which take the format:
    sum( FieldYouWantToSum, GroupToTakeFieldsFrom )
    so, something like:
    sum( {product_price}, {product_group} )
    (and placing it in the group header) should be what you are after.
    You could, of, course, use the Insert Summary wizard to do this for you.

  • RTF Template: sums with nested groups

    Hi all,
    i've got quite a pickle of a problem it seems ...
    my data structure looks something like this:
    <COMPANY>
    --<STORE>
    ----<DEPARTMENT>
    ------<ITEM></ITEM>
    ----</DEPARTMENT>
    --</STORE>
    </COMPANY>
    multiple companies can have multiple stores, which in turn have multiple departments, which also in turn can have multiple items.
    my select statement looks something like this:
    select company_id,
    store,
    department,
    item,
    sum(qty) as my_sum
    from
    table_1, table_2, table_n
    where ...
    group by ...
    order by company_id;
    my xml data template grouping looks something like this:
    <group name="G_company" ...
    --<element name="E_company" ...
    --<group name="G_store" ...
    ----<element name="E_store" ...
    ----<group name="G_department" ...
    ------<element name="E_department" ...
    ------<group name="G_item" ...
    --------<element name="E_item" ...
    --------<element name="E_item_total" value="my_sum" ...
    ------</group>
    ------<element name="E_department_total" value="G_item.E_item_total" function="SUM()" />
    ----</group>
    ----<element name="E_store_total" value="G_department.E_department_total" function="SUM()" />
    --</group>
    </group>
    my report currently looks something like:
    ------------------<b>Store</b>--------<b>Dept</b>---------<b>Dept</b>---------<b>Item</b>-----------<b>Item</b>---------------<b>Store</b>-----------<b>Dept</b>----------<b>Item</b>-----------<b>Item</b>
    <b>Company</b>---Townsville---TDept_1------TDept_2-----TDItm1----------TDItm2-------------Newcastle------NDept1----------NDItm1--------------NDItm2
    ---CompanyA------2----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    ---CompanyB------1----------------2------------4---------------5---------------2------------------1-------------------6----------------3-------------------1
    if i just focus on the Store --> Department --> Item, i achieved this in my RTF template by doing something like the following:
    <table>
    --<tr>
    ----<td><?for-each-group@column:G_store;E_store?>Store</td><td><?for-each-group@column:G_department;E_department?>Department</td><td><?for-each-group@column:G_item;E_item?>Item<?end for-each-group?> <?end for-each-group?> <?end for-each-group?> </td>
    --</tr>
    --<tr>
    ----<td><?for-each-group@column:G_store;E_store?><?E_store_total?></td><td><?for-each-group@column:G_department;E_department?><?E_department_total?></td><td><?for-each-group@column:G_item;E_item?><?E_item_total?><?end for-each-group?> <?end for-each-group?> <?end for-each-group?> </td>
    --</tr>
    </table>
    as you can see, the store --> department --> item go across the report horizontally.
    my problem is i want to have grand totals for each column, like:
    ------------------<b>Store</b>--------<b>Dept</b>---------<b>Dept</b>---------<b>Item</b>-----------<b>Item</b>---------------<b>Store</b>-----------<b>Dept</b>----------<b>Item</b>-----------<b>Item</b>
    <b>Company</b>---Townsville---TDept_1------TDept_2-----TDItm1----------TDItm2-------------Newcastle------NDept1----------NDItm1--------------NDItm2
    ---CompanyA------2----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    ---CompanyB------1----------------2------------4---------------5---------------2------------------1-------------------6----------------3-------------------1
    ---<b>Total</b>------------3----------------6------------6---------------7---------------3------------------2-------------------9----------------5-------------------5
    so i did a SUM on each of the E_store/department/item_totals like:
    <?sum(current-group()/E_store_total)?>
    now that works for E_store_total ... but not for E_department_total and E_item_total!
    it seems BI Publisher doesn't like sums used with inner loops.
    because if i extract just the column for E_department, the grand total value at the bottom is correct!
    but once i put back the outer store loop, it breaks.
    what i am currently getting with this is:
    ------------------<b>Store</b>--------<b>Dept</b>---------<b>Dept</b>---------<b>Item</b>-----------<b>Item</b>---------------<b>Store</b>-----------<b>Dept</b>----------<b>Item</b>-----------<b>Item</b>
    <b>Company</b>---Townsville---TDept_1------TDept_2-----TDItm1----------TDItm2-------------Newcastle------NDept1----------NDItm1--------------NDItm2
    ---CompanyA------2----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    ---CompanyB------1----------------2------------4---------------5---------------2------------------1-------------------6----------------3-------------------1
    ---<b>Total</b>------------3----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    it is doing the grand total for Store correctly, but it just gives me the first row for the other grand totals.
    i have tried:
    1. using the CUBE function in my SQL query, which gives me the results i want with all the totals i want, except i cannot seem to translate it into XML.
    2. trying to use the pivot table option but i can't seem to ever get it to work the way i want.
    3. using a separate sql query to retrieve the grandtotals but that doesn't work either because of the multiple looping required.
    i'm at a complete dead end, any help would be really appreciated!
    ps. i'm a very fresh newbie

    Hi Vetsrini,
    thank you very much!
    when you said to use current-group i was confused because i thought i was using it, but when i opened up the RTF template i realized you meant the actual looping.
    so instead of doing:
    <?for-each-group@column:G_DEPARTMENT;E_DEPARTMENT?>
    <?sum(current-group()/E_STORE_TOTAL)?>
    i should have been doing:
    <?for-each-group@column:current-group()//G_DEPARTMENT;E_DEPARTMENT?>
    <?sum(current-group()/E_ITEM_TOTAL)?>
    thanku!
    S.

  • Using a sum formula with a data and text row?

    In 9.3.1 Financial reporting.
    One row is retrieving values from essbase connection and is a data row
    the second row is a fixed amount (390K) and was entered as a text row.
    The third row is the formula row that sums up row 1 and row 2
    However the total shows only the value of the data row (row 1)
    I read the doc and it doesn't say you cannot do a formula between data and text rows but it doesn't see to work. Anyone get by this without having to create a dimension to dump a fixed number in to report off of?
    JTS

    You are right on.. A text row by definition and functionality is to be considered as a text, and not as a number [Even though the text can be number based].
    Did you try something like this?
    sum(row[41],390)
    As you referred, you can always add a member in essbase DB
    Cheers
    RS

  • Formulas and Groups

    Post Author: vondee
    CA Forum: Crystal Reports
    I have a report grouped by year, with a percent total for each year that is calculated in a formula from running totals:
    2004 - XX%
    2005 - XX%
    2006 - XX%
    2007- XX%
    I want to add a formula next to the percent that calculates the difference between that year's XX% and the previous year.  So the result of 2007 XX% - 2006 XX% appears in the 2007 group.  The result of 2006 XX% - 2005 XX% appears next to 2006, etc.
    Is this possible in Crystal?  Thanks for any ideas-

    Post Author: kcheeb
    CA Forum: Crystal Reports
    Seems to me there's a prevrow function that can be used to return a value. Not sure if I'm remembering correctly or not and what the behaviour is in a group.

  • Sum formula in XL Reporter

    Dear all,
    When I am using XL reporter, I would like to get the sum of the expanding section in the next row. I've tried =sum(ixref(D12,2)) in D11 cell, but it doens't work.
    Please kindly help.
    Thank you!
    Regards,
    Julie

    Dear Gordon,
    Thank you for your reply.
    I've tried a couple of times and realized the formula =sum(ixref(d11, 2) works for upper and lower vertically. The reason why it didn't work is because I created a row expanding section for an account code in row D.
    Anyway, it works fine now.Thank you!
    Regards,
    Julie

Maybe you are looking for