Count and sum function

Hi,
I want to get sum of a column, but it is giving wrong values when using sum and count functions. please help.
But in actual excel value is different.

Hi,
Below is the derived table query:
select location,
SUM(case when priority='1'and sholders like '%niit%'then 1 else 0 end) as 'Total P1callsof NIIT',
SUM(case when Priority='1'and sholders like '%niit%'and sla_violation=0 then 1 else 0 end) as 'TotalResolvedcallsinBHRS NIIT'
from Stakeholders group by Location
Am calculating the sum of 'Total P1callsof NIIT' in a summary page, which gives me incorrect value(2349) where the actual count is 581. .

Similar Messages

  • COUNT() and SUM() function it not working in XDO file.

    Hi ,
    I am getting one error. Count and sum function not working proper.
    For example :
    Department 10 have 3 employee and total salary is 8750. But my report returning total employee 1 and total salary 5000
    10
    Ename Sal
    KING 5000
    CLARK 2450
    MILLER 1300
    ==================
    total employee : 1
    total salary : 5000
    Kindly help me solve this problem.
    <dataTemplate name="TEXT">
    <properties>
    <property value="upper" name="xml_tag_case" />
    </properties>
    <lexicals>
    </lexicals>
    <dataQuery>
    <sqlstatement name="Q_TEMP">
    <![CDATA[SELECT DEPTNO,DNAME,LOC FROM DEPT]]>
    </sqlstatement>
    <sqlstatement name="Q_TEMP1">
    <![CDATA[SELECT ENAME,HIREDATE,SAL FROM EMP WHERE DEPTNO = :DEPTNO]]>
    </sqlstatement>
    </dataQuery>
    <datastructure>
    <GROUP name="G_1" source="Q_TEMP">
    <element value="DEPTNO" name="DEPTNO" />
    <element value="DNAME" name="DNAME" />
    <element value="LOC" name="LOC" />
    <GROUP name="G_2" source="Q_TEMP1">
    <element value="ENAME" name="ENAME" />
    <element value="SAL" name="SAL" />
    <element value="G_2.ENAME" name="TOTL_DETAILS" dataType="number" function="COUNT()" />
    <element value="G_2.SAL" name="TOTL_SAL" function="SUM()"/>
    </GROUP>
    </GROUP>
    </datastructure>
    </dataTemplate>
    Thanks
    Yudhi

    Please have the data structure as below:
    <datastructure>
    <GROUP name="G_1" source="Q_TEMP">
    <element value="DEPTNO" name="DEPTNO" />
    <element value="DNAME" name="DNAME" />
    <element value="LOC" name="LOC" />
    <GROUP name="G_2" source="Q_TEMP1">
    <element value="ENAME" name="ENAME" />
    <element value="SAL" name="SAL" />
    *</GROUP>*
    *<element value="G_2.ENAME" name="TOTL_DETAILS" dataType="number" function="COUNT()" />*
    *<element value="G_2.SAL" name="TOTL_SAL" function="SUM()"/>*
    *</GROUP>*
    </datastructure>
    Aggregate functions to be placed at the level you require it. Here you need at G_1, so place it there.

  • Count and Sum running total

    Can i sum and couunt running total in formula?.
    Please let me know.

    Hey, we can do count and sum functions in Running total.
    These functions are available in crystal reports for  summary fields.
    We can create  the running total based on the type of summary like Sum, count, max, min, distinct count, etc.
    We can do Evaluation for each record or on group or on each field  and also be done by writing a formula.
    We can  do count or sum by manual running total by writing a formula in the formula workshop.
    Based on our requirement we can use both functionalities.
    Please let me know  if you have any queries.
    Regards,
    Naveen.

  • Help with count and sum query

    Hi I am using oracle 10g. Trying to aggregate duplicate count records. I have so far:
    SELECT 'ST' LEDGER,
    CASE
    WHEN c.Category = 'E' THEN 'Headcount Exempt'
    ELSE 'Headcount Non-Exempt'
    END
    ACCOUNTS,
    CASE WHEN a.COMPANY = 'ZEE' THEN 'OH' ELSE 'NA' END MARKET,
    'MARCH_12' AS PERIOD,
    COUNT (a.empl_id) head_count
    FROM essbase.employee_pubinfo a
    LEFT OUTER JOIN MMS_DIST_COPY b
    ON a.cost_ctr = TRIM (b.bu)
    INNER JOIN MMS_GL_PAY_GROUPS c
    ON a.pay_group = c.group_code
    WHERE a.employee_status IN ('A', 'L', 'P', 'S')
    AND FISCAL_YEAR = '2012'
    AND FISCAL_MONTH = 'MARCH'
    GROUP BY a.company,
    b.district,
    a.cost_ctr,
    c.category,
    a.fiscal_month,
    a.fiscal_year;
    which gives me same rows with different head_counts. I am trying to combine the same rows as a total (one record). Do I use a subquery?

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    user610131 wrote:
    ... which gives me same rows with different head_counts.If they have different head_counts, then the rows are not the same.
    I am trying to combine the same rows as a total (one record). Do I use a subquery?Maybe. It's more likely that you need a different GROUP BY clause, since the GROUP BY clause determines how many rows of output there will be. I'll be able to say more after you post the sample data, results, and explanation.
    You may want both a sub-query and a different GROUP BY clause. For example:
    WITH    got_group_by_columns     AS
         SELECT  a.empl_id
         ,     CASE
                        WHEN  c.category = 'E'
                  THEN  'Headcount Exempt'
                        ELSE  'Headcount Non-Exempt'
                END          AS accounts
         ,       CASE
                        WHEN a.company = 'ZEE'
                        THEN 'OH'
                        ELSE 'NA'
                END          AS market
         FROM              essbase.employee_pubinfo a
         LEFT OUTER JOIN  mms_dist_copy             b  ON   a.cost_ctr     = TRIM (b.bu)
         INNER JOIN       mms_gl_pay_groups        c  ON   a.pay_group      = c.group_code
         WHERE     a.employee_status     IN ('A', 'L', 'P', 'S')
         AND        fiscal_year           = '2012'
         AND        fiscal_month          = 'MARCH'
    SELECT    'ST'               AS ledger
    ,       accounts
    ,       market
    ,       'MARCH_12'          AS period
    ,       COUNT (empl_id)       AS head_count
    FROM       got_group_by_columns
    GROUP BY  accounts
    ,            market
    ;But that's just a wild guess.
    You said you wanted "Help with count and sum". I see the COUNT, but what do you want with SUM? No doubt this will be clearer after you post the sample data and results.
    Edited by: Frank Kulash on Apr 4, 2012 5:31 PM

  • How can I obtain a summary report from webi through counts and sum

    I have a report built from webi. But will like to count the report by different categories.

    Hi Cobimah,
    You have several options. You can simply add totals to the measure columns where you want a count or sum. Click on the column and then click the Sum button on the menu and you can count, sum, min, max, etc.
    If you want a separate summary report, you can place formulas in the cells like =Sum([Measure Object]) or Count([Measure Object]), or create a variable as the same and place it in the cell.
    You also have the option of creating the pre-aggregated objects in the Universe and then they are already there for you to use where you like if they are aggregations that you will be using often.
    Thanks

  • Problem with group by and sum function

    In one of the report I'm using grioup by clause on one column. However when I use this function the sum function on other column is not working.
    Any idea how we can resolve this?

    Hi Tintin,
    Follow the below steps:
    1) On the order number column formula, use the max function.
    2) Duplicate the revenue column in the RPD, set the aggregation to sum and level to transaction. This will give you the sum of all the orders in a particular trasaction, where as in report you will see only the max account number.
    Assign points if helpful.
    Thanks,
    -Amith.

  • Using ABS and Sum function at a time

    <?if: sum(ARCH_AMT)!='0' ?>
    we were using above condition in the template to restrict data till date,but we were facing a new problem when ARCH_AMT is having multiple lines with same amount but +ve and -ve i.e 500,-500 it's doing sum and not returning data since sum would be zero.
    we need to do ABS(ARCH_AMT) before doing sum so that SUM will be thousand and data will be picked up.
    please suggest how can we have ABS and sum at a time
    i tried
    <?if: sum(ABS(ARCH_AMT))!='0' ?> and also choose conditions and It's not working.
    thanks in advance.
    Kind Regards,
    Mahi
    Edited by: mahi4luck on Mar 28, 2012 2:33 AM

    store ABS(ARCH_AMT) in a variable, and use that variable in a running total
    example:
    suppose i have an xml structure like this:
    <CATALOG>
    <AMOUNT>
    <ARCH_AMT>-500</ARCH_AMT>
    </AMOUNT>
    <AMOUNT>
    <ARCH_AMT>500</ARCH_AMT>
    </AMOUNT>
    </CATALOG>
    <?xdoxslt:set_variable($_XDOCTX,'vTotal',0)?>
    <?xdoxslt:set_variable($_XDOCTX,'vAbsAmt',0)?>
    <?for-each:AMOUNT?>
    <?xdoxslt:set_variable($_XDOCTX,'vAbsAmt',xdoxslt:abs(ARCH_AMT))?>
    <?xdoxslt:set_variable($_XDOCTX,'vTotal', xdoxslt:get_variable($_XDOCTX, 'vAbsAmt') + xdoxslt:get_variable($_XDOCTX,'vTotal'))?>
    <?end for-each?>
    Total: <?xdoxslt:get_variable($_XDOCTX, 'vTotal')?>

  • Count and Sum show different in Summary tab

    Hello friends,
    Webi 4 version
    I have a webi dcument with 4 report tabs. Summary, Expense,Revenue and Forecasting.
    I have a SUM value in Expense tab and Revenue tab. I also have Count value in Forecasing.When I copy these SUM and Count values to Summary tab, they show different values than those in other tabs.
    Please help me to resolve this
    Thanks
    Renpal

    Hi Renpal,
    Even if we write the aggregate values in to a variable and if you copy that variable in Summary tab it may not give the same result.For Example.
    If count of Sales orders in Detail tab is showing as 500 and in Summary tab it may show as 489. This is because in Detail tab there might be some cells which are "#" or Not assigned. so due to granularity it will count each and every cell, incase of summary all # or Not Assigned are calculated as 1.
    Can you check wrt the above example where exactly the data is not matching.
    Regards,
    G.SaiNath

  • MDX How to get total distict count and SUM of subgroups?

    with
    MEMBER Measures.[EmailCount] as IIF(ISEMPTY([Measures].[Tran Count]), 0 ,[Measures].[Tran Count])
    MEMBER Measures.AdvGroupTotal as
    SUM (
    FILTER( EXISTING ([Dim IFA Details].[Parent Key].[Adviser Group].Members * [Dim Date].[Fiscal].[Fiscal Year].members )
    , Measures.[Amount] > 100 )
    , Measures.[Amount])
    MEMBER Measures.[AdvGrpCount] as
    distinctCOUNT(Existing([Dim IFA Details].[Parent Key].[Adviser Group].Members * [Dim Date].[Fiscal].[Fiscal Year].members))
    member Measures.IncomePerEmail as Measures.AdvGroupTotal /Measures.[EmailCount]
    member Measures.AvgIncomePerFirm as Measures.AdvGroupTotal/ Measures.AdvGrpCount
    SELECT { [Measures].[Amount] , Measures.[EmailCount], Measures.AdvGroupTotal, Measures.[AdvGrpCount],
    Measures.IncomePerEmail, Measures.AvgIncomePerFirm }
    ON COLUMNS,
    [Dim Date].[Fiscal Year].[Fiscal Year].ALLMEMBERS * [Dim Date].[Fiscal Quarter].[Fiscal Quarter].ALLMEMBERS *
    Except( [Dim Income Range].[Hierarchy].[Range ID].Members , [Dim Income Range].[Hierarchy].[All].UNKNOWNMEMBER.UNKNOWNMEMBER )
    on rows
    FROM [Income and Emails Cube]
    where
    [Dim Date].[Fiscal].[Fiscal Year].&[FY 13/14]
    The query above returns :
    How can I get Totals for AdvGroupTotal and AdvGroupCount for the year ?
    In the above case I want to tally up 1586 + 67 + 155 + 12 + 1718 for AdvGroupCount, same applies for the corresponding
    AdvGroupTotal figures.
    Seems simple enough, but I seem unable to come up with a way around this.
    Jon

    I worked it out with the help of Simon from another forum.
    Using a filtered set will get me the result required. It is however not very quick, so I probably should look into building it into the cube.
    WITH SET [Filtered Groups] AS
    ( Filter (
    { [Dim IFA Details].[Parent Key].[Adviser Group] } *
    { [Dim Date].[Fiscal Year].CurrentMember },
    [Measures].[Amount] > 100
    MEMBER [Measures].[Annual] AS
    Sum ( [Filtered Groups], Measures.[Amount] )
    MEMBER [Measures].[Firm Count] AS
    DistinctCount ( [Filtered Groups] )
    MEMBER [Measures].[Avg Income Per Firm] AS
    [Measures].[Annual] / [Measures].[Firm Count]
    MEMBER [Measures].[Test] AS
    Sum (
    { [Dim Date].[Fiscal Quarter].[Fiscal Quarter] } * { [Dim Income Range].[Hierarchy].[Range ID] } * { [Filtered Groups] },
    [Measures].[Amount]
    MEMBER [Measures].[TotalCount] AS
    DistinctCount (
    { [Dim Income Range].[Hierarchy].[Range ID] } * { [Filtered Groups] }
    MEMBER [Measures].[TotalAvg] as [Measures].[Test]/ [Measures].[TotalCount]
    MEMBER [Measures].[Quarter] as [Measures].[Amount]
    SELECT
    { [Measures].[Quarter], [Measures].[Annual], [Measures].[Firm Count], [Measures].[Avg Income Per Firm],
    [Measures].[Test], [Measures].[TotalCount], [Measures].[TotalAvg] } ON COLUMNS,
    [Dim Date].[Fiscal Year].[Fiscal Year].AllMembers * [Dim Date].[Fiscal Quarter].[Fiscal Quarter].AllMembers *
    Except ( [Dim Income Range].[Hierarchy].[Range ID].Members, [Dim Income Range].[Hierarchy].[All].UnknownMember.UnknownMember )
    DIMENSION PROPERTIES Member_Unique_Name, MEMBER_CAPTION
    ON ROWS
    FROM [Income and Emails Cube]
    WHERE [Dim Date].[Fiscal].[Fiscal Year].&[FY 13/14]

  • Use Windows PowerShell to count and list total number of items in Folders E-Mail in Office Outlook?

    I have the need to generate a list of all outlook folders and the total number of items listed beside each folder name. I thought I could simply modify the script from " http://blogs.technet.com/b/heyscriptingguy/archive/2009/01/26/how-do-i-use-windows-powershell-to-work-with-junk-e-mail-in-office-outlook.aspx
    " regarding the total number of items in the junk folder but no luck.
    I thought I could just simply duplicate line 6 of the aforementioned script
    "$folder = $namespace.getDefaultFolder($olFolders::olFolderJunk) " and change the folder name but getting the "Method invocation failed because [Microsoft.Office.Interop.Outlook.OlDefaultFolders] does not contain a method
    named 'olFolder'.
    At line:7 char:1
    + $folder = $namespace.getCurrentFolder($olFolders::olFolder("Design Engineering S ...
    I've found a way to export a list of all these folders using exportoutlookfolders.vbs to a txt file but doesn't include total number of items.
    Looking for any pointers on how to make this work. Don't expect anyone to write it for me but I am still learning PS. Would be great to find a way to import all of these folder and subfolder names into the script. Will be appreciative of any advice though.
    There's an enormous amount of Outlook folders.
    Outlook 2013
    Windows 8
    Thanks,
    Barry

    Since I am not and administrator, but an end user, I do not have access to the Get-Mailxxxx commandlets to make this really easy and had to do this long hand.
      The following will pull folder.name, folder.items.count, and sum the total size of each folder's items for all folders and their subs. 
    Just one warning, the summation can take some time with a large PST file since it needs to read every email in the PST. 
    There is also some minor formatting added to make the results a little more readable.
    $o
    = new-object
    -comobject outlook.application 
    $n
    = $o.GetNamespace("MAPI") 
    $f
    = $n.GetDefaultFolder(6).Parent 
    $i
    = 0
    $folder
    = $f
    # Create a function that can be used and then re used to find your folders
    Function
    Get-Folders()
    {Param($folder)
     foreach($folder
    in $folder.Folders)   
    {$Size =
    0
    $Itemcount
    = 0
    $foldername
    = $folder.name
    #Pull the number of items in the folder
    $folderItemCount
    = $folder.items.count
    #Sum the item (email) sizes up to give the total size of the folder
    foreach ($item
    in $folder.Items)
    {$Itemcount
    = $Itemcount
    + 1
    $Size =
    $Size +
    $item.size
    Write-Progress -Activity ("Toting size of "
    + $foldername
    + " folder.")
    -Status ("Totaling size of "
    + $Itemcount
    + " of "
    + $folderItemCount
    + " emails.")
    -PercentComplete ($itemcount/$folderItemCount*100)
    # just a little formating of the folder name for ease of display
    While($foldername.length
    -le 19){$foldername
    = $foldername
    + " "}
    #Write the results to the window
    Write-Host ("-folder "
    + $foldername
    + "  
    -itemcount " +
    "{0,7:N0}" -f
    $folderItemCount +
    "   -size " +
    "{0,8:N0}" -f ($size/1024)
    + " KB")
    #If the folder has a sub folder then loop threw the Get-Folders function.
    #This two lines of code is what allows you to find all sub folders, and
    #sub sub folders, and sub sub sub for as many times as is needed.
    If($folder.folders.count
    -gt 0)
    {Get-Folders($folder)}
    get-folders($folder)

  • How can I sum up raws? the sum function seems to work for columns only and right now I have to create a separate formula for each raw

    How can I sum up raws? the Sum function seems to work only on columns. Right now I have to create a separate formula for each raw

    Hi dah,
    "Thanks, but can I do one formula for all present and future raws? as raws are being added, I have to do the sum function again and again"
    You do need a separate formula for each group of values to be summed.
    If the values are in columns, you need a copy of the formula for each column.
    If the values are in rows, you need a copy of the formula for for each row.
    If you set up your formulas as SGIII did in his example (shown below), where every non-header row has the same formula, Numbers will automtically add the formula to new rows as you add them.
    "Same formula" in this context means exactly the same as all the formulas above, with one exception: the row reference in each formula is incremented (by Numbers) to match the row containing the formula.
    Here the formula looks like this in the three rows shown.
    B2: =SUM(2)
    B3: =SUM(3)
    B4: =SUM(4)
    That pattern will continue as rows are added to the table.
    Also, because the row token (2) references all of the non-header cells in row 2, the formula will automatically include new columns as they are added to the table.
    Regards,
    Barry

  • Sum() function not working properly. Instead of summing, its showing total count of the rows

    We have migrated one application from .net framework 1.0 to .net framework  2 (from Visual studio 2003 to Visual STUDIO 2005). Now after migration we are facing some problem related to the sum function in Crystal report 10. It is not working properly.
    So we migrated to Crystal report XI release 2 (though still using evaluation version for testing purpose), the problem is not yet resolved.
    The problem we are facing is while using the summary in the group field, it is showing the number of rows instead of the sum of the values.
    We have checked the same with min-max functions, and it is working properly with those.
    We have tried to make the sum by formula field. In such case, it is not showing any syntactical error but at execution time, it is throwing an error saying "A number field or currency amount field is required here".
    In the  the report the datatype of the field on which we are applying the sum function, is number, and in the table from where the data is fetched, the datatype is numeric(9,6).
    Any idea why sum function is not working ?
    I was browsing the net and saw running totals can be a work around for such summation issues in Crystal Report XI.
    Can you please provide insight of how to implement running totals for summation purpose in solving such issues.

    Hi,
    Running totals are more accurate than Summary Totals in Crystal.  Why? ...ask Crystal.  Anyway, just right click on Running Totals, create a new one, and enter you fields, etc. For group totals, it gives you a place to reset the totals for each group, etc.  Pretty self explainatory. 
    Jim

  • Use COUNT or MAX functions inside of a query, and you have no data found

    I'm writing a query with a COUNT and a MAX function.
        SELECT  li.id
                 , MAX(m.display_date)
                , COUNT(*)
         FROM li JOIN m  ON (m.LIID=li.LIID)
        WHERE m.DISPLAY_DATE < SYSDATE - 7
        GROUP BY  li.id;I would like to write a query that returns always a row foe each row in the table li.
    If there are no records with the condition "WHERE m.DISPLAY_DATE < SYSDATE - 7", I would like to have a row with
    - COUNT(*) = 0
    - MAX(m.display_date) = TO_DATE('2010-06-08', 'YYYY-MM-DD'

    user600979 wrote:
    I'm writing a query with a COUNT and a MAX function.
    SELECT  li.id
    , MAX(m.display_date)
    , COUNT(*)
    FROM li JOIN m  ON (m.LIID=li.LIID)
    WHERE m.DISPLAY_DATE < SYSDATE - 7
    GROUP BY  li.id;I would like to write a query that returns always a row foe each row in the table li.
    If there are no records with the condition "WHERE m.DISPLAY_DATE < SYSDATE - 7", I would like to have a row with
    - COUNT(*) = 0
    - MAX(m.display_date) = TO_DATE('2010-06-08', 'YYYY-MM-DD'In that case tell me what do you want to display in the ID column. That is the first column?

  • Sum function not working properly in Crystal XI. Its showing total count of the values

    We have migrated one application from .net framework 1.0 to .net framework  2 (from Visual studio 2003 to Visual STUDIO 2005). Now after migration we are facing some problem related to the sum function in Crystal report 10. It is not working properly.
    So we migrated to Crystal report XI release 2 (though still using evaluation version for testing purpose), the problem is not yet resolved.
    The problem we are facing is while using the summary in the group field, it is showing the number of rows instead of the sum of the values.
    We have checked the same with min-max functions, and it is working properly with those.
    We have tried to make the sum by formula field. In such case, it is not showing any syntactical error but at execution time, it is throwing an error saying "A number field or currency amount field is required here".
    In the  the report the datatype of the field on which we are applying the sum function, is number, and in the table from where the data is fetched, the datatype is numeric(9,6).
    Any idea why sum function is not working ?
    I was browsing the net and saw running totals can be a work around for such summation issues in Crystal Report XI.
    Can you please provide insight of how to implement running totals for summation purpose in solving such issues.

    Are you seeing this happen in the Crystal designer as well, outside of any .NET application?

  • Help with drop down box if/then function and sum

    Hi, I am hoping someone can help me with an if/then function. I have a drop down box with all of the provinces listed, then based on their choice I need to calculate provincial sales tax with a sum function for the price of the item plus the sales tax. Help!

    You can enter the sales tax rate for each province as the export value and
    then use the drop-down field directly in your calculations.
    On Thu, Feb 5, 2015 at 6:06 PM, jennam90934439 <[email protected]>

Maybe you are looking for

  • I am trying to install a program on my Mac and the Automator is interfering....can it be overridden or disabled?

    I purchased a program from a trusted website and was able to download it....however when I try to install it I get an "Apple Run Script Error"....the support team for the web site thinks it is Automator....so not sure how to get around this....anyone

  • Default Theme is no longer available in Themes form

    For a long I've used (and still do) the Charamel Theme in Firefox v3.6.13 under Window XP SP3 ENG. When I used then Main Menu >> Tools >> Extensions I've always seen an entry regarding the Charamel Theme as well as an entry regarding the Default Them

  • Incoming Payment in FC

    Dear All, My client says that they are not able to see the field "Doc.Currency field in the "Incoming Payments" screen where they used to enter the foreign currency exchange rate. Earlier, thy entered some transcations where they entered the exchange

  • How to put a user defined class in Web dynpro

    How and where can we create some user defined classes? For example i wanted to create some utility classs for my project. Under what folder should i create this?

  • Photoshop CS 8.0 - How do I Deactivate

    Trying to deactivate my Photoshop CS version 8.0. Under the 'Help' menu there is no Deativation link (there is a 'Activate' one that is grayed out, and doesn't work).