Sum of Average Field

Post Author: jehanzeb
CA Forum: Crystal Reports
Hello all,
I am wondering how can you get a grand total of "Average". I have a field in the report with Average per day per lense. Now at the end of the report I would like to show the grand total of all those averages.
Example:
Average Per day
2.00
3.00
1.50
At the end of the page (footer) it should show grand total of 6.50.
How can I achive this?
Help pleaseeee
I have tried sum, count, distrnt count etc but none seems to be working (tried the summary function key as well).
Regards
Jehanzeb

Post Author: jehanzeb
CA Forum: Crystal Reports
Morning Khalil,
Firstly thanks for the kind reply. I have tried your explained method but unfortunately it didn't work, infact it has changed the values to 1.00 all the way.
Example -
Whileprintingrecords;Global Numbervar FAvg:=0; ( This stayed at it is and has been inserted onto the header - upon initialisation it is shown as 0 which is fine).
Whileprintingrecords;Numbervar FAvg;FAvg := FAvg+ {lab_rework.rework_qty}; ( The rework qty is the field which needs to be averaged - example  from 01/05/2008 to 02/05/2008 there were 3 lenses which were reworked, so the average should be 1.5 per lense per day. However, using your formula it shows 1.00)
Whileprintingrecords;Numbervar FAvg; (This is the grand total of whatever the average field shows however this is showing 1.00 as well even though the records are showing 1.00, in theory this should add up all those 1.00s and should show 10.00 which it isnt.)
I have tried using the built in average running total but it doesnt seem to work as it calculates the average of the first day and not all days. For example when I entered the date range from 01/05/2008 to 02/05/2008, it shows the average of the 01/05/08 day and not the total average of both days hence showing only 1.00 as it calculating only one day. This however should calculate the average of the days I enterd into the parameters i.e. according to the date range
how can I achive the expected results (where it shows the average of all the lenses reworked according to the date range)?
Many thanks
Regards
Jehanzeb

Similar Messages

  • 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

  • Dump when summing up CURR field in ALV GRID display

    Hi All,
    I am getting dump when I try to sum the CURR field in my ALV Grid Display. The field is of CURR 23.  I am using classes and methods to display alv grid.
    I tried passing <fs_fieldcat>-do_sum = 'X'. When I did this, it is dumping without even displaying the alv grid.
    Here is the part it is throwing dump:
            ls_lvc_data-value = space.
            clear ls_lvc_data-style.
            loop at it_fcat_local assigning <ls_fcat>
                    where tech ne 'X' and no_out ne 'X'.
              if l_invisible eq 'X'.
                clear l_invisible.
                if <ls_fcat>-do_sum is initial.
                  continue.
                else.
                  clear ls_lvc_data-col_pos.
                endif.
              endif.
              add 1 to ls_lvc_data-col_pos.
              assign component <ls_fcat>-fieldname
                               of structure <ls_data> to <l_field_value>.
              _if sy-subrc ne 0.
                message x000(0k).
              endif._
    Regards,
    Guru

    Thomas,
    Here is the dump:
    Runtime Errors         MESSAGE_TYPE_X
    Date and Time          10/22/2010 23:30:53
    Short text
    The current application triggered a termination with a short dump.
    What happened?
    The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X).
    Error analysis
    Short text of error message:
    Long text of error message:
    Technical information about the message:
    Message class....... "0K"
    Number.............. 000
    Variable 1.......... " "
    Variable 2.......... " "
    Variable 3.......... " "
    Variable 4.......... " "
    How to correct the error
    Probably the only way to eliminate the error is to correct the program.
    If the error occures in a non-modified SAP program, you may be able to
    find an interim solution in an SAP Note.
    If you have access to SAP Notes, carry out a search with the following
    keywords:
    "MESSAGE_TYPE_X" " "
    "SAPLSLVC" or "LSLVCF36"
    "FILL_DATA_TABLE"
    If you cannot solve the problem yourself and want to send an error
    notification to SAP, include the following information:
    1. The description of the current problem (short dump)
    To save the description, choose "System->List->Save->Local File
    (Unconverted)".
    2. Corresponding system log
    Display the system log by calling transaction SM21.
    Restrict the time interval to 10 minutes before and five minutes
    after the short dump. Then choose "System->List->Save->Local File
    (Unconverted)".
    3. If the problem occurs in a problem of your own or a modified SAP
    program: The source code of the program
    In the editor, choose "Utilities->More
    Utilities->Upload/Download->Download".
    4. Details about the conditions under which the error occurred or which
    actions and input led to the error.
    Source Code Extract
    Line
    SourceCde
    2708
    is_subtottxt_info = ls_subtot_info
    2709
    ip_subtot_line    = lr_data
    2710
    changing
    2711
    c_subtottxt       = l_subtottxt.
    2712
    ls_lvc_data-value = l_subtottxt.
    2713
    2714
    append ls_lvc_data to ct_lvc_data.
    2715
    endif.
    2716
    2717
    2718
    Column per Fieldcat Entry
    2719
    2720
    ls_lvc_data-value = space.
    2721
    clear ls_lvc_data-style.
    2722
    loop at it_fcat_local assigning <ls_fcat>
    2723
    where tech ne 'X' and no_out ne 'X'.
    2724
    if l_invisible eq 'X'.
    2725
    clear l_invisible.
    2726
    if <ls_fcat>-do_sum is initial.
    2727
    continue.
    2728
    else.
    2729
    clear ls_lvc_data-col_pos.
    2730
    endif.
    2731
    endif.
    2732
    2733
    add 1 to ls_lvc_data-col_pos.
    2734
    2735
    assign component <ls_fcat>-fieldname
    2736
    of structure <ls_data> to <l_field_value>.
    2737
    if sy-subrc ne 0.
    >>>>>
    message x000(0k).
    2739
    endif.
    2740
    2741
    *... work on average
    2742
    if <ls_fcat>-do_sum eq 'C'.
    2743
              Initialize average result and entries
    2744
    <l_field_value> = 0.
    2745
    clear l_entries.
    2746
    2747
              retrive unit from fieldcatalog
    2748
    assign space to <l_unit>.
    2749
    if not <ls_fcat>-cfieldname is initial.
    2750
    assign component <ls_fcat>-cfieldname
    2751
    of structure <ls_data> to <l_unit>.
    2752
    endif.
    2753
    if not <ls_fcat>-qfieldname is initial.
    2754
    assign component <ls_fcat>-qfieldname
    2755
    of structure <ls_data> to <l_unit>.
    2756
    endif.
    2757

  • 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

  • Sum of Averages?

    Hello All,
    Am extremely frustrated at this point so i thought I'd post here and maybe someone can help me with a solution.  I have a report that I created that shows me the average amount of charges for a day.  How do I take a sum of the averages for for each day?  If i try to insert a summary and then use the average field it gives me an error.  Anyways around this?

    Since you are able to get the avg amt for each charge ID then create formula like this
    whileprintingrecords;
    numbervar i;
    i:=i+Average value calcualted;
    Place this in ChargeID group footer.
    Now create another formula like this
    whileprintingrecords;
    numbervar i;
    Place this in report footer which shows the sum of average.
    Hope this helps!
    Regards,
    Raghavendra

  • Sum of a field in ALV List

    Hello Guys,
    I'm using 'REUSE_ALV_GRID_DISPLAY' in my prog.
    There is a field in output table which is of type P(8) Decimals 3.
    When I'm trying to get the sum of this field in ALV Display it gives the message " Desired operation cannot be performed for column 'Converted Quantity' ".
    I have also tried do_sum = 'X'.
    But it is not working. Please help guys.
    Regards,
    Abhinav

    Thanks a lot guys for your inputs.
    The program is working now.
    Now I'm using :
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname = 'QUAN'.
    *  wa_fieldcat-ref_tabname = 'I_OUT2'.
    *  wa_fieldcat-tabname = 'I_OUT2'.
      wa_fieldcat-qfieldname = 'MEAS'.
      wa_fieldcat-qtabname = 'I_OUT2'.
      wa_fieldcat-outputlen = '15'.
      wa_fieldcat-seltext_l = text-052.
      APPEND wa_fieldcat TO i_fieldcat.
    The program is working fine now.
    I have commented tabname and -ref_tabname , and the program is working fine now.
    Thanks a lot.

  • SUM for a field in ALV

    Hello Guys,
    CAn any one tell me how to do the SUM for a particular column in ALV.It should display at the End of the records.The column field is TYPE N(4).
    My CODE is like this:
    CLEAR fc_tmp.
      fc_tmp-col_pos         =  5.
      fc_tmp-reptext_ddic    = 'POINTS'.
      fc_tmp-fieldname       = 'POINTS'.
      fc_tmp-tabname         = 'ITAB'.
      fc_tmp-outputlen       = 15.
      fc_tmp-key             = 'X'.
      fc_tmp-do_sum          = 'X'.
      APPEND fc_tmp TO fieldcat.
    This is not working.
    Thanks in Advance,
    Take care

    Hi,
    populate the IT_SORT internal table of REUSE_ALV_GRID_DISPLAY provided in the importing parameters.
    fieldname = Company Code
    append fieldname to it_sort.
    fieldname = division.
    append fieldname to it_sort.
    If you explicitly need subtotals then add the following line
    subtot = 'X'
    For obtaining sum you have an attribute "do_sum" in fieldcatalog , set it to 'X' and you should be able to do sum on that field.
    <b>Ensure that these should be numeric / currency or quantity datatypes only.</b>
    wa_fieldcat-datatype = 'CURR'.   or
    wa_fieldcat-datatype = 'QUAN'.
    Hope this solves your problem
    Cheers,
    Simha.
    PS : Please reward points if solution is helpful

  • Material description filled automatically as the sum of two fields

    Hello to all
    We can automate the process of the creation a new material doing that the field material description(MAKT-MAKTX) can be filled by the system before saving(not by the user) as the sum of two fields in the MARA table that the users will be filled manually.
    Is it possible using a user exit, field exit,....?
    Thanks in advance.
    Regards

    Hello to all
    We can automate the process of the creation a new material doing that the field material description(MAKT-MAKTX) can be filled by the system before saving(not by the user) as the sum of two fields in the MARA table that the users will be filled manually.
    Is it possible using a user exit, field exit,....?
    Thanks in advance.
    Regards

  • [CR integrated in VS 2005] - sum of string fields

    Hello,
    i am discovering CR,
    and i am trying to do the sum of a field (number) but declared as string. the declaration of the field cannot be changed (string in the database).
    so i want to do the sum of this field.
    i wonder if it is possible, and if yes, how.
    maybe something like a formula.
    I saw the functions: ToNumber () and Cdbl() for conversion, and Sum().
    If someone has an idea, i will be very interested.
    PS: sorry if my question is not understandable, i'm french. If you don't understand it, i would rewrite it.
    thank you!

    thank you.
    I could convert, but the problem is to make the sum of the conversion.
    i would like to do something like:
    Sum(ToNumber ()) but CR does not accept it.
    Maybe by using a variable in a formula (but i don't know where):
    shared numbervar total;
    total = total+ToNumber({MyField});
    and when printing a formula field at the bottom of the report to show the total:
    shared numbervar total;
    ToText (total);

  • A Beginners Outcry: Homework of sum and Average

    Dear all,
    I am a java dummie. This is what happens intuitively in my mind. I need a program that runs to calculate the sum and average of either positive or negative inputed integers. The maximum input integers = 100. As defined, sn = sum of negative integers, sp = sum of positive, in = count of negative integers, ip = count of positive integers. If input integer = 0, the program comes to an end. If input integer is non zero, the outcomes would be sum of negative and sum of positive, average of negative and average of negative. I think I should use do-while statement, but..... Also, for the input, should I input a list of integers....Can someone show me the code plus some brief explanation that a beginner like me would be able to understand? Thanks.

    yawmark wrote:
    Can someone show me the code plus some brief explanation that a beginner like me would be able to understand?
    [So, You Need to Write a Program but Don't Know How to Start|http://home.earthlink.net/~patricia_shanahan/beginner.html].
    ~Ta. I just read through that article again, and again I find myself in awe of the sageness of such simple advise... I'm bookmarking it, to reread whenever I feel like tearing my hair out over a problem.
    Cheers. Keith.

  • How to calculate sum of the fields in adobeforms

    Hello Experts
    can  i know how to calculate sum of fields in the adobe form.  I have few fields to be summed in total field.
    Regards

    Hello Surendra,
         Suppose you are having 4 fields and the 4th field is the TOTAL field.
         Write the below Javascript on the Initialize event of TOTAL field as shown below.
    Remember that if you use just "+" sign without Number() or ParseInt() function it acts like String Concatenation.
    this.rawvalue = Number( this.parent.field1.rawvalue ) +
                          Number( this.parent.field2.rawvalue ) +
                          Number( this.parent.field3.rawvalue ) ;
    You can also write is as shown below.
    this.rawvalue = parseInt( this.parent.field1.rawvalue ) +
                             parseInt( this.parent.field2.rawvalue ) +
                             parseInt( this.parent.field3.rawvalue ) ;

  • Subtotals - sum of average column

    Hi,
    I am new to PowerPivot so please excuse me if this is a stupid question.  I have a pivot table that uses a SQL view as its data source.  The pivot table looks like this:
    Price = average
    Qty = sum
    Value = sum
    Budget = average
    The way the view has been written the budget figure is given to grouping Customer + Product + MonthYear.  So, if I drop it into the pivot table as an average it comes up correctly.  The problem for me is that I want to turn on subtotals
    and get the sum of the average'd budget lines in the rowgroup above.  I have read that I can do this with PowerPivot by createing measures.  I guess my question really is "How do I use a measure in place of a subtotal in a pivot table
    report - how would I drag and drop it into place so it repeats as a subtotal would?"  The next question would be how would I write this measure?
    TIA

    Hi Julina,
    I had seen those threads before but didn't quite understand them.  I have got it now.  This is the formula that I have come up with, but I still get the averages of the averages, and not the sum of the averages:
    IF(COUNTROWS(VALUES(vwComprehensiveDeliveries_YRN[CustomerName]))>1,
    SUMX(
    SUMMARIZE(
    vwComprehensiveDeliveries_YRN,
    vwComprehensiveDeliveries_YRN[CustomerName],
    vwComprehensiveDeliveries_YRN[Product],
    vwComprehensiveDeliveries_YRN[BL_Year],
    vwComprehensiveDeliveries_YRN[BL_Qtr],
    vwComprehensiveDeliveries_YRN[BL_Month],
    "Customer Subtotal", AVERAGE(vwComprehensiveDeliveries_YRN[BudgetValue])
    [Customer Subtotal])
    AVERAGE(vwComprehensiveDeliveries_YRN[BudgetValue])
    I have tried it with only grouping SUMMARIZE by CustomerName, and combinations of the ones you see above. What have I done wrong?
    Thanks,
    C

  • Sum a DATETIME field

    Just noticed it isn't straight forward to SUM a DATETIME fields.
    I’ve used the following code to get the time, how do I convert the output back to a DATETIME field?
    declare @T table
    total_hours_worked datetime
    insert into @T values ('01:00:00')
    insert into @T values ('01:30:00')
    insert into @T values ('03:35:00')
    select *
    from @T
    select SUM((DATEPART(hh,total_hours_worked)*60)+DATEPART(mi,total_hours_worked)+(DATEPART(ss,total_hours_worked)/(60.0)))/60.0 as TotalHours from @T
    Thanks,

    I should have added the disclaimer that my solution would require total_hours_worked to be stored as either a float or a varchar to be used with the function I described above.   The completed functions would be similar to 
    CREATE FUNCTION dbo.TimeSpan_CreateFromString
    @pFormattedTimeSpan varchar(128) = null
    RETURNS float(53)
    with returns null on null input AS
    BEGIN
    declare @DayPortion int
    ,@HourPortion int
    ,@MinutePortion int
    ,@SecondPortion decimal(6,4)
    declare @l int
    declare @s2 varchar(128)
    DECLARE @Result float(53)
    select @s2=LTRIM(rtrim(@pFormattedTimeSpan))
    set @l = LEN(@s2)
    declare @i int
    if CHARINDEX('.',@s2,1) < CHARINDEX(':',@s2,1)
    begin
    set @i = CHARINDEX('.',@s2,1)
    select @DayPortion =
    case CHARINDEX('.',@s2)
    when 0 then 0
    else
    case ISNUMERIC(SUBSTRING(@s2,1,CHARINDEX('.',@s2)-1))
    when 1 then CAST(SUBSTRING(@s2,1,CHARINDEX('.',@s2)-1) as int)
    else 0
    end
    end;
    set @s2=ltrim(rtrim(SUBSTRING(@s2,@i+1,@l-(@i))))
    end
    else
    begin
    set @DayPortion=0
    end
    -- ** debug: select @i, @l, @s2
    --select CHARINDEX(':',@s2,1) [c1], CHARINDEX(':',@s2,CHARINDEX(':',@s2,1)+1) [c2], CHARINDEX(':',@s2,(CHARINDEX(':',@s2,CHARINDEX(':',@s2,1)+1))+1) [c3]
    set @i = CHARINDEX(':',@s2,1)
    select @HourPortion =
    case CHARINDEX(':',@s2,1)
    when 0 then 0
    else
    case ISNUMERIC(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1))
    when 1 then CAST(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1) AS int)
    else null
    end
    end
    set @s2=ltrim(rtrim(SUBSTRING(@s2,@i+1,@l-(@i))))
    -- ** debug: select @i, @l, @s2
    set @i = CHARINDEX(':',@s2,1)
    select @MinutePortion =
    case CHARINDEX(':',@s2,1)
    when 0 then 0
    else
    case ISNUMERIC(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1))
    when 1 then CAST(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1) AS int)
    else null
    end
    end
    set @s2=ltrim(rtrim(SUBSTRING(@s2,@i+1,@l-(@i))))
    -- ** debug: select @i, @l, @s2
    set @i = CHARINDEX(':',@s2,1)
    select @SecondPortion =
    case ISNUMERIC(@s2)
    when 0 then null
    else CAST(@s2 as decimal(6,4))
    end
    SELECT @Result = dbo.TimeSpan_CreateFromParts(@DayPortion,@HourPortion,@MinutePortion,@SecondPortion);
    RETURN @Result
    END
    GO
    I changed the function names to make them more consistent.

  • Sum of a field

    I am having issues trying to do sum of a field.
    This is how the source data looks like:
    COLA COLB COLC COLD
    123 456 4 X
    123 456 4 A
    123 456 4 B
    123 789 5 Y
    123 789 5 Z
    123 789 5 E
    Output I want is:
    COLA COLB COLC COLD COLE COLF COLG COLH COLI
    123 789 9 X A B Y Z E
    max(COLB) (5+4)
    The sumof COLC based on ColB
    Any suggestions, please let me know...
    Thanks..

    COLC is 9 because there are just unique values for COLB. ColA is my primary key but I am joining to 2 tables where there is one to many relationships and thats why the data looks like above.
    As far as COLD goes, there is a unique code for every value in COLD and I am doing a decode along with MAX and trying to normalize the data, but my problem is I dont know how to just get just the 2 values from COLC to do the sum.

  • Sum and average of a list of integers

    heya all
    im trying Implement a program to find the sum and average of a list of integers terminated by the data marker -999.
    import java.util.*;
    public class sumaverage
       public static void main(String[] args)
    int sum = 0;     // input the first number
           int num = kybd.nextInt(); // kybd is an instance of Scanner
           while ( num != -999 )    // while the end of data not found
                sum += num ;
                num = kybd.nextInt(); // input the next number
           System.out.println("the sum is " + sum );
    }}Currently im getting " cant find symbol" on lines 10 + 16 pointing at the k in kybd.nextInt(); , could anyone tell me whats wrong as im lost ?
    Thankyou

    thanks mate , i cant belive i missed that :S
    im now trying to add the adverage to the code
    ive done the following coding , can anyone confirm this is correct ? it all compiles fine ...
    import java.util.*;
    public class sumaverage
       public static void main(String[] args)
         Scanner kybd = new Scanner(System.in);
         int sum = 0;     // input the first number
         int n;
         double Adverage = 0;
           int num = kybd.nextInt(); // kybd is an instance of Scanner
           while ( num != -999 )    // while the end of data not found
                sum += num ;
             n = kybd.nextInt();
                sum += n;
             Adverage = sum/n;
                num = kybd.nextInt(); // input the next number
           System.out.println("the sum is " + sum );
           System.out.println("The adverage of the integers is " + Adverage);
    }}

Maybe you are looking for

  • Jre 6u26 installation troubles on Windows 7 64 bit

    I've noticed that in my system was installed jre till update 24 and nothing earlier. So I tried to install new version of jre (6u26) but installation process ends immediatlu after UAC prompt, without any error message. I unistalled every kind of jre

  • DVI- HDMI discoloration on HDTV (as second monitor)

    Hello all. I have been having some issues when using my Philips CRT 30" 1080i HDTV as a second monitor via a DVI->HDMI cable. There seems to be a discoloration that occurs (my best guess being a "green" discoloration) that occurs in the top left corn

  • Run time error in MIGO after maintaining tax code

    Hello Experts, I had configured the new tax code ,which is working fine for the PO document ZLOC domestic and the account category Z. While doing the MIGO for purchase document type ZGEN general purchase , I am getting run time error:   "Division by

  • EHP7 Upgrade stuck in NTACT_ALTNT Phase

    Dear Experts, Am stuck in the upgrade NTACT_ALTNT phase of the EHP7 upgrade Source: SAP ECC6.0 Target: SAP ECC 6.0 EHP7 In the preprocessing phase got an error in the        MAIN_SHDIMP/SUBMOD_SHD2_RUN/NTACT_ALTNT     phase. Please find the logs belo

  • Local variable versus 'properity value'

    Hi, can anybody explain me the (dis-)advantages of using 'properity:value' instead of using a local variable when I want to read (write) a control at a second location. Thanks for any input Urs Bögli