Sums by columns

Dear All,
my table looks like :
Class Product
Time amount 
Cars A
2011   10
Cars A
2012 15
Bike B
2011 3
Bike B
2012 5
I want to create a first column named Sum_Class which calculates the sum of all values of column amount for each class by time
the expected result :
Class Product
Time amount 
Sum_Class
Cars A
2011   10
25
Cars B
2011 15
25
Cars A
2012 3
8
Cars B
2012 5
8
thank you in advance for your help
Regards
Toufik

so you basically need the sum over all times for each class
AllTimes:=CALCULATE(
SUM('Facts'[Amount]),
ALL('Facts'[Time])
to be even more generic you may use ALLEXCEPT
AllTimes2:=CALCULATE(
[Sum_Class],
ALLEXCEPT('Facts', 'Facts[Class])
hth,
gerhard
Gerhard Brueckl
blogging @ http://blog.gbrueckl.at
working @ http://www.pmOne.com

Similar Messages

  • How to sum the column in a table seperated by sign.

    How to sum the column in a table separate by sign.
    For Example:
    A B
    10 MOHAN
    -15 KUMAR
    -25 MARCH
    50 MAY

    SELECT  SUM(CASE SIGN(A) WHEN 1 THEN A ELSE NULL END) SUM_POSTIIVE,
            SUM(CASE SIGN(A) WHEN -1 THEN A ELSE NULL END) SUM_NEGATIIVE
      FROM  tbl
    /SY.

  • How to Suppress Report Total When Using Sum on Columns & Break Formatting

    I need to know how to NOT show the report total line when using the sum functionality with a break in a report.
    I am summing two columns, a debit amount and credit amount. I am breaking on the first column which is the level of a hierarchical query. I want to see something like this:
    Parent Record xxxxxxxxxxxxxx
    Parent Sum $$ $$
    Child Record xxxxxxxxxxxxxx
    Child Record xxxxxxxxxxxxxx
    Child Sum $$ $$
    However, when I run the report, I also get a report total line under the child sum which is really meaningless for this report.
    I have also tried creating this report as an interactive report. When applying the sum on the two columns, I do get the sum totals on the break only - no report total - however, it is reversing the order of the hierarchical query results putting the child records first and the parent records second.
    Thanks in advance for your help.

    Hi, and welcome!
    I don't think that there's an easy way to "switch off" the Total line on a report. The nearest I could suggest would be to either hide the entire row or colour the text so that it's the same as the background - either way, the total is calculated but the user won't see it.
    If you put something like the following into your report region's Region Footer:
    <script type="text/javascript">
    var outertable = document.getElementById("#REGION_ID#");
    var innertable = outertable.getElementsByTagName("TABLE")[1];
    var rs = innertable.rows;
    var lastrow = rs[rs.length-1];
    if (lastrow.cells[0].innerHTML == '<b>TOTAL</b>')
    rs[rs.length - 1].style.display = "none";
    </script>Then, on your report's Report Attributes page, scroll down to the Break Formatting section and put TOTAL into the "Display this text when printing report sums" setting. Also, in the "Layout and Pagination" section, set "Enable Partial Page Refresh" to No.
    The above code is based on the report and region templates that I'm using here: [http://apex.oracle.com/pls/otn/f?p=267:147] (Theme 18, "Report Region" region template and "Standard" report template). Your report may use different templates, so the first two lines on the code may have to change. #REGION_ID# would be replaced with the region's ID value (which would be "R" followed by a long number). As long as you can identify the HTML tag that uses this ID value, you can then get to the actual table that contains the data as it would be a TABLE within that tag - the [1] above is the second table within the region. In some instances, you may have to use "region_#REGION_ID#" as the starting point.
    Andy

  • Sum of columns in union query

    hi, i am using oracle 10g database..
    how to get the sum of column in union query ?
         select * from (select 100 records from dual), (select 50 available from dual)
    union
    select * from (select 200 records from dual), (select 150 available from dual)
    display should be like
                     records         available
                      100               50
                      200               150
    total            300               200thanks ...

    Peter vd Zwan wrote:
    try this:Grouping by records will not produce correct results:
    SQL> with a as
      2  (
      3  select * from (select 100 records from dual), (select 50 available from dual)
      4  union
      5  select * from (select 100 records from dual), (select 100 available from dual)
      6  union
      7  select * from (select 200 records from dual), (select 150 available from dual)
      8  )
      9  select
    10    case when grouping(records) = 0 then null else 'total' end tot
    11    ,sum(records)   records
    12    ,sum(available) available
    13  from
    14    a
    15  group by
    16  rollup (records)
    17  ;
    TOT      RECORDS  AVAILABLE
                 200        150
                 200        150
    total        400        300
    SQL> select  case grouping(rownum)
      2     when 1 then 'Total'
      3   end display,
      4          sum(records) records,
      5          sum(available) available
      6    from  (
      7            select * from (select 100 records from dual), (select 50 available from dual)
      8           union
      9            select * from (select 100 records from dual), (select 100 available from dual)
    10           union
    11            select * from (select 200 records from dual), (select 150 available from dual)
    12          )
    13    group by rollup(rownum)
    14  /
    DISPL    RECORDS  AVAILABLE
                 100         50
                 100        100
                 200        150
    Total        400        300
    SQL> SY.

  • How to sum a column in SQL server??

    How do I sum a column called 'expenditureamount' in a sql table 'expenditureform', such that I get the total expenditure amount displayed in a text box??

    You can sum it with the SQL SUM function, of course, but what that has to do with how your program display that sum, I don't know. IOW, how you display is not anything related to JDBC, and how you SUM it is not anything related to JDBC. The first one is SQL (check on an SQL forum or Google for it) and the second depends on how you want to display it, and there are more appropriate forums than the JDBC one, for that.

  • How to sum subgrid column in CRM 2013

    Hi,
    I want to sum Subgrid column named "Quantity" and show in alert.

    Hi,
    You can also try this code to calculate subgrid amount total for crm 2013.
    Add your subgrid name in place of "testing"  and amount field name in place of 'new_amount'.
    function RetrieveSubGridRecords() {
        if (document.getElementById("testing")) {
            var grid = document.getElementById("testing").control;
            var ids = grid.get_allRecordIds();
            var sum = 0.00;
            var cellValue;
           for(i = 0; i < ids.length; i++) {
               var cellValue = grid.getCellValue('new_amount',ids[i]);
               var number = Number(cellValue.replace(/[^0-9\.]+/g,""));
               sum = sum + number;
           alert('s'+sum);
        else {
           setTimeout("RetrieveSubGridRecords();", 2500);
    Hope this help..
    Thanks

  • Sum 2 columns in alv report (not separately)

    Hi,
    I have an alv report and I use do_sum = 'X' in order to sum separately 2
    columns.
    The demand here is that at the end of the report there will also be
    a total of the 2 columns together.
    I tried to implement it but so far - no success.
    Mayby someone has an idea ??
    Promise to award points...
    Thanks.
    Ruthie.

    Hi,
    For summing say column EBELN, MATNR for eg.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
       fieldcatalog-outputlen   = 10.
      <b>fieldcatalog-do_sum      = 'X'.</b>
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      <b>fieldcatalog-do_sum      = 'X'.</b>
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    You will get the sum at the end also, try this.

  • Can you sum a column in FormsCentral?

    Similar to how you would sum a column of numbers in a Excel spreadsheet, Can you sum a column in FormsCentral or are you required to only do this once it has been saved to an Excel sheet?
    Regards
    kevin

    One of my biggest grievances with Forms Central is the lack of any kind of calculating (living in hope Adobe!)... you will have to do it in Excel.

  • CFGRID - Sum of Column Values

    Hi,
    Is there a way to sum | total a column of numeric values in a
    cfgrid? I want to populate a cfinput text box with the number, and
    bind it so that as changes to numbers occur on the grid, the
    cfinput box changes.
    I've been able to do this by creating a function that goes
    and extracts the information via a database query. Running the
    query seems to add overhead to the screen response time.
    The variable could start as a value passed from a query. Say
    2000. When a field changes, it would take the original value,
    subtract out the original "row" value, then add in the new "row"
    value. Say a 2 is being replaced by a 3. Then you'd have 2000-2+3 =
    2001 which becomes the new "original" total value.
    Any thoughts would be appreciated.
    cfwild

    Hi Dan,
    Thanks for the feedback. The grid really works well for what
    I'm trying to do. I can filter the pages and make minor changes to
    the data quite quickly. When I add in the extra function (to sum
    the column) that goes out to the table to extract the data, it
    seems to take a performance hit on the "page".
    In looking at the code I've seen, it seems easy(?) to get to
    the new value of the column. Is there a decent way to get to the
    "old" value of the column, prior to an update? (or as you update)?
    cfwild

  • Sum datagrid column values

    I am looking for a way (action script code?) to sum datagrid
    column values.
    I am using Flex2 with Cold Fusion MX7.
    I populate a DataGrid by setting dataprovider to the result
    of a Coldfusion query.
    (this.masterList.dataProvider = event.result as
    ArrayCollection;)
    This all works fine.
    The masterList datagrid has debit, credit, and unitcost
    columns. I want to sum those columns individually, and display the
    results in text boxes in another panel.
    I could run a Coldfusion query to return the sums, but would
    like to do it on the client side with action script.
    I want to sum them everytime I update the datagrid, so need
    action code that I can put in the result function.
    I am new to ActionScript, and not sure how to loop through
    the array collection(and/or) dataprovider and sum the items.
    Any help would be appreciated.
    Thanks.

    Loop through your array..if the arrayCollection was named
    myArray;
    private sumFunction():Number{
    var sum:Number=0;
    for(var i:uint=0;i<myArray.lenght;i++){
    sum+=myArray
    .debitValue;
    return sum;

  • How do I dynamicaly sum a column in Pages without specifiying start/end?

    How do I dynamicaly sum a column without specifiying a start/end range?
    I want to add a new row anytime and have that sum total reflect the new row value.

    The best answer will depend upon knowing what file format.  Audacity app is a popular answer but if you are dealing with a lossy format such as AAC/.m4a or .mp3 you are better off using using editing tools for those (MPEGStreamclip and MP3Trimmer respectively).

  • How to sum a column value using CAML Query?

    Hi All,
    I would like to sum the column value using CAML qeury. Actually in my list, I have two column "Projects Name" and "Number of Issues". Now need to get sum of "Number of Issues" column. How to achieve in CAML Query.
    Thanks in advance!

    Hi Sam,
    it looks like you can use your current view based agregation, otherwise it is not possible(
    http://msdn.microsoft.com/en-us/library/ms467521.aspx) and you need to work on custom bit on this requirement.
    use the below link and create a view element as described and see if that works for you
    Aggregations Element
    http://msdn.microsoft.com/en-us/library/ms468626%28v=office.12%29.aspx
    Another reference
    Query Element
    http://msdn.microsoft.com/en-us/library/ms471093.aspx
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • APEX Interactive Report - sum multiple columns table1 X with table2 value

    I have a challenge in oracle apex, were i want to sum multiple columns to give 3 extra rows namely points, Score, %score. There are more columns but chose only few for now.
    Below is an example structure of my data:
    Town | Sector | Outside| Inside |Available|Price
    Roy-----Formal----0----------0----------1------0
    Kobus Formal--0 ---------0--------- 1------0
    Wika ---Formal----0----------0--------- 1------0
    Mevo----Formal----1----------1---------1------0
    Hoch----Formal----1----------1---------1-------1
    Points--------------2----------2----------5-------1
    Score-------------10---------10---------10------10
    %score-----------20---------20---------50------10
    Each column has a constant weighting (which serves as a factor and it can change depending on the areas) in this case the weighting for this areas are the ones in the first row for the sector Formal:
    Sector |Outside| Inside |Available|Price
    Formal----1----------1 ----------1-----1
    Informal--1----------0 ----------2-----1
    I tried using the aggregate sum function in apex but it wont work since i need the factor in the other table. Which is where my challenge started
    To compute the rows below the report:
    points = sum per column * weighting factor per column
    Score = sum of no of shops visited (in this case its 5) * weighting factor per column
    % score = points/Score * 100
    The report should display as described above. With the new computed rows below.
    I kindly ask anyone to assist me with this challenge as i tried searchin on the internet for solutions but havent come across any.
    Thanks a lot for your support in advance!!

    >
    Please update your forum profile with a real handle instead of "823433".
    I have a challenge in oracle apex, were i want to sum multiple columns to give 3 extra rows namely points, Score, %score. There are more columns but chose only few for now.
    Below is an example structure of my data: Use <tt>\...\</tt> tags as described in the FAQ when posting code and sample data and layouts. Please edit the OP and reformat the example using <tt>\...\</tt> tags so it's clear.
    Town | Sector | Outside| Inside |Available|Price
    Roy-----Formal----0----------0----------1------0
    Kobus --Formal----0 ---------0--------- 1------0
    Wika ---Formal----0----------0--------- 1------0
    Mevo----Formal----1----------1---------1------0
    Hoch----Formal----1----------1---------1-------1
    Points--------------2----------2----------5-------1
    Score-------------10---------10---------10------10
    %score-----------20---------20---------50------10Each column has a constant weighting (which serves as a factor and it can change depending on the areas) in this case the weighting for this areas are the ones in the first row for the sector Formal:
    Sector |Outside| Inside |Available|Price
    Formal----1----------1 ----------1-----1
    Informal--1----------0 ----------2-----1I tried using the aggregate sum function in apex but it wont work since i need the factor in the other table. Which is where my challenge started
    To compute the rows below the report:
    points = sum per column * weighting factor per column
    Score = sum of no of shops visited (in this case its 5) * weighting factor per column
    % score = points/Score * 100
    The report should display as described above. With the new computed rows below.
    I kindly ask anyone to assist me with this challenge as i tried searchin on the internet for solutions but havent come across any.How critical to the solution is using an interactive report? It would be much easier to do this in a standard report where you've complete control over the query SQL and the report structure.
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.

  • Runtime Error while summing a column in ALV output

    Dear All,
    I have developed an ALV Report and the report is giving output without any flaws.
    I have defined proper field catalog and displaying the results using REUSE_ALV_GRID function module.
    Now the report is generating Runtime Error while the user selects a column and click the SUM icon.
    The fields like Qty, or amounts are also theowing runtime error while summing up their column in the ALV output.
    What might be the reason and how to resolve this issu?
    Regards
    Pavan

    Hi ,
    I don't know how you have write  down the code but follow the below coding example:
    FOR TOTAL:
    there is a property of fieldcatalog, that is do_sum.
    USE COED LIKE:
    PERFORM fieldcat USING:
    '1' 'MATNR' 'I_MARD' 'MATERIAL NO' 'MARD' 'MATNR ' ' ',
    '2' 'NETWR' 'I_MARD' 'PLANT' 'MARD' 'WERKS' ' ',
    FORM fieldcat USING value(p_0029)
    value(p_0030)
    value(p_0031)
    value(p_0032)
    wa_fieldcat-col_pos = p_0029.
    wa_fieldcat-fieldname = p_0030.
    wa_fieldcat-tabname = p_0031.
    wa_fieldcat-reptext = p_0032.
    wa_fieldcat-do_sum = 'X'.
    APPEND wa_fieldcat TO i_fieldcat.
    ENDFORM. " FIELDCAT
    in final output you will get the total of currency field.
    FOR SUB TOTAL:
    decleare: i_sort type standard table of slis_sortinfo_alv,
              wa_sort type slis_t_sortinfo_alv.
    wa_sort-spos = '1'.
    wa_sort-fieldname = 'field1'.
    wa_sort-subtot = 'X'.
    append wa_tab to i_sort.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    it_fieldcat = it_fieldcat
    it_sort = i_sort
    Hope this can solve your pbs.
    If you need more inputs let me know.
    Regards,
    Tutun

  • How to sum different column in the same table

    Hi everyone
    I would like to know how can I make the sum of different column in the same table using apex
    exple:
    TR_PROJ_BIL_TRIM.ENTPIDFISC as ENTPIDFISC,
        TR_PROJ_BIL_TRIM.EXEANNEE as EXEANNEE,
        TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV as PROJBILTRIMT1PREV,
        TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV as PROJBILTRIMT2PREV,
        trunc( TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV)+(TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV)
    from TR_PROJ_BIL_TRIM TR_PROJ_BIL_TRIM
    group by TR_PROJ_BIL_TRIM.ENTPIDFISC,TR_PROJ_BIL_TRIM.EXEANNEE
    but while trying to run this script i get this error message:"ORA-00979: not a GROUP BY expression"
    thanks for reading me and I hope to hear from you soon

    Hi,
    Your question do not have anything do with APEX.
    It is pure SQL question and you will get better answer this kind questions from SQL and PL/SQL forum
    You need have GROUP BY when you use aggregate functions like SUM.
    I assume you like just add two columns.
    Try
    SELECT ENTPIDFISC
        ,EXEANNEE
        ,PROJBILTRIMT1PREV
        ,PROJBILTRIMT2PREV
        ,trunc(PROJBILTRIMT1PREV) + (PROJBILTRIMT2PREV)
    FROM TR_PROJ_BIL_TRIM
    Regards,
    Jari

  • How do I SUM filtered column set only in FormsCentral View Responses?

    Hello... When I use the FormsCentral "view responses" tab's excel spreadsheet report, I can't seem to SUBTOTAL any columns once they have been filtered!
    I only see an option for adding SUM in the last row, but it calculates all of the filtered and unfiltered amounts together anyway... How can I only add up and report the amount for the filtered set selected??
    Thank you!  -Chris

    Hi wcanerday,
    Thanks for the green tick and your feedback. Yes, the SUMIF function is powerful!
    When you adapt the Personal Budget template, make sure that the items in the Category Column (A) on the Budget sheet exactly match the items in the Pop-Up Menus in Column C of the Transactions sheet.
    Editing a Pop-Up Menu in Numbers 3 is easy. Please call back if you need more help.
    Regards,
    Ian.

Maybe you are looking for

  • Is there a way to make the spark checkbox directional?

    Hi All, Is there a (easy) way to make the checkbox with the text on the left to the quare? Thanks in advance, Lior

  • Upgrading lightroom 5 to lightromm cc

    I have been trying to upgrade lightroom 5 to lightroom cc. I am a creative cloud member and my operating system meets the rquirements. Despite folowong all of the on screen instructions lighroom cc still does not appear in creative cloud app

  • Macbook pro auto wake from sleep every minute lid open or closed

    Macbook Pro 2.53, OSX10.8.5. Since I installed Lion, my Macbook pro will not sleep for longer than one minure. Even with the lid closed it still wakes up. Charger on or off. Force sleep works, but auto wake after a minute. Have reset SMC, deleted pri

  • Sharing with other computers

    Hello I have a tower pc on xp with itunes 7.5. Everyone other computer in my house has a laptop with wireless connections to a router that is also connected to my pc via a network lead. Now on itunes all their music appears in the left hand column. H

  • Problems for Japanese users with ELS

    We have some (but not all) Japanese users reporting errors at the point in our startup where we read the ELS (Encrypted Local Store). We've run a test application that saves and reads objects to and from the ELS. When reading an object we just wrote,