Running Total & Distinct Count Query

Crystal 10.0.0.533 CR Professional
Hope you can assist.
I have a report listing deals signed, each deal has a corresponding category i.e. industry type, Accountant, Chiropractor, Financial Services, etc.
I am undertaking a Distinct Count on these categories so that in the group footer it is showing number of different categories signed in a period (the report is grouped into different date periods). This is working OK.
However, I need to EXCLUDE the category from this distinct count if the deal value is zero.
I have tried using a formula to show a blank field if the value is zero, however it appears to be distinctly counting the blank as a category?
Any assistance would be much appreciated.
Tracy

Deffinetly it will be less than what you expect for grand total. It is because when you are calculating distinct count for each group suppose
Group A has categories A,B,C,D-->distinct count (4)
Group B has C,D,E,F-->distinct count (4)
but while calculating grand total then the distinct count will be
A,B,C,D,E,F --> grand total (6) but not (8).
In this case you need to use mannual running total like this
whileprintingrecords;
numbervar i;
i:=i+{running total};
place this in group footer and create another fomula like this
whileprintingrecords;
numbervar i;
place this in report footer to get the correct grand total.
Regards,
Raghavendra

Similar Messages

  • How to do running totals in a query

    Hi Guys, I have following data sample and desired output and I need a running total or subtotals on each row for two quntity fields on same row.
    Current data:
    ID - ---Day----- Qty1 Qty2
    Abc 04/01/2009 100 50
    abc 04/02/2009 70 20
    def 04/01/2009 10 30...
    Desired outPut:
    ID - ---Day----- Qty1 Subtoal Qty1 Qty2 SubtotalQty2
    Abc 04/01/2009 100 100 50 50
    abc 04/02/2009 70 170 20 70
    def 04/01/2009 10 180 30 30

    Hi,
    There's one thing in your example, regarding the last line:
    def 04/01/2009 10 180 30 30I assumed you meant:
    def 04/01/2009 10 180 30 100 <<== running total should be 100Am I correct?
    Then try:
    SQL> with t as (
      2  select  'Abc' col1, to_date('04/01/2009', 'dd/mm/yyyy') col2, 100 col3, 50 col4 from dual union all
      3  select'abc', to_date('04/01/2009', 'dd/mm/yyyy'), 70, 20 from dual union all
      4  select 'def', to_date('04/01/2009', 'dd/mm/yyyy'), 10, 30 from dual
      5  ) --Actual query starts here:
      6  select col1
      7  ,      col2
      8  ,      col3
      9  ,      sum(col3) over (order by rownum) rt_col3
    10  ,      col4
    11  ,      sum(col4) over (order by rownum) rt_col4
    12  from t;
    COL COL2             COL3    RT_COL3       COL4    RT_COL4
    Abc 04-01-2009        100        100         50         50
    abc 04-01-2009         70        170         20         70
    def 04-01-2009         10        180         30        100Edited by: hoek on Jun 24, 2009 5:19 PM added question

  • Running Total Issue:  How to calculate counts excluding suppressed records

    Post Author: benny
    CA Forum: Formula
    Hello All:
    I have a current report that gives the total counts of work requests.   However, in my section expert, there are some records in the detail that are suppressed (if there isn't any backlog). The current running totals are counting all the records including the suppressed records. I think I need three formulas:1. Calculate the counts2. Calculate the counts excluding suppressed records3. Reseting the counts by group
    May I ask if someone can give me an example of what I should do?
    Thanks so much!
    Benny

    Post Author: benny
    CA Forum: Formula
    Bettername,
    Actually, I should have been more specific.  This report is actually a PM backlog report.  It displays all the work requests (PM) issued including the backlogged. There are 9 columns (including one called Backlog) for the different counts of the pm's based from the status codes (Issued, Material on Order, Completed, Cancelled, etc) of the work requests. The detail records of worke requests are grouped by shop and PM end date.  The running totals are calculated at the pm date group level (group footer#2). Then based from those at the shop group level (group footer#1) there is a grand total of counts of the running totals. The detail records and pm end date group header (group header #2) are suppressed.
    Now the foremen would like the report to just display all the backlogged PMs. Using the section expert, I suppressed all the PM issued that have no back log ({@ backlog = 0}) and just display the back logged pm's.  This is where I run into the running total issue.
    This is very involved report and I will use the column PM Issued as an example.  I can still use the same logic as you suggested?
    1. declaration formula:
    whileprintingrecords;numbervar pmissued := 0;
    2. Suppression formula that uses the variable:
    whileprintingrecords;
    numbervar pmissued;
    if ({@ backlog = 0}) then pmissued:= pmissed else pmissued:=pmissuedr+1
    3. Display formula:whileprintingrecords;
    numbervar pmissued;
    If this is the right track, then I can use the same example for the other columns. 
    Thanks so much.
    Benny

  • Error when using running total variable in formula

    This is probably an easy syntax problem, but I'm fairly new to Crystal reporting.  I created a running total variable (count) called InquiryTypeSubtotal that simply counts the number of records.  I have one grouping level, and in the group footer I'd like to print a line showing the total count for that group that looks like
    Total inquiries for Assistive Technology: 3
    To accomplish this I'm using a formula field with the following syntax:
    "Total inquiries for " + {CnAttrCat_1.CnAttrCat_1_Description} + ": " + ToText(@InquiryTypeSubtotal)
    When I try to check the formula, I get the error message "The ) is missing."  What am I doing wrong?
    Thanks,
    Alec

    I put in the curly brackets so my formula now reads
    "Total inquiries for " + {CnAttrCat_1.CnAttrCat_1_Description} + ": " + ToText({@InquiryTypeSubtotal})
    Now when I check the formula I get the error message "This field name is not known."
    Alec

  • Manual Running Total vs Running Total

    Morning all,
    It is some what strange to me when I try to use a formula to calculate the total jobs and when I try to use Running total to count the same total jobs. Both answers in theory should be the same however they are not. I am wondering where am I going wrong in the manual formula.
    If {despatch_summary.job_type}="FSV" then
    if {despatch_summary.order_status}<>0 then
    {despatch_summary.order_no}
    else
    0
    The above code then gets DistinctCount ({@FSV})
    The same method if I use by using Running Total it gives the correct number of jobs.
    Running Total
    field to summarize : despatch_summary.order_no
    Summary Type: DistinctCount
    Formula: {despatch_summary.job_type}="FSV" and {despatch_summary.order_status}<>0
    Reset: none
    The formula gives me 513 where as the same running total gives me 514
    Where am I going wrong?
    Strangely it is adding 1 to all of my manual running totals (1 is coming from canceled orders).
    Many thanks
    Regards

    Sastry I am adding this formula into the crosstab which is setup by Number of days. So on the column it is number of days and on the summarized field it is this formula.
    I chose Group options and clicked on DistinctCount after adding the formula into the summarized field.
    I have already tried the formula you have suggested however it doesn't seem to be affecting it.
    Apart from that what I have just done is added the Running Totals to the Summarized field which is coming up correctly however now the problem is to get their percentages.
    I have used the following code but it doesn't seem to be working.
    Whileprintingrecords;
    Numbervar g:=Currentfieldvalue;
    Numbervar h:={@TotalJobs-CanceledJobs};
    Numbervar i:=0;
    i:=((g/h)*100);
    Numbervar gTot:=gTot+i;
    if gTot > 100 then "100.00%"
    else
    totext(gTot,2)+"%"
    I know I am doing it wrong when it comes to percentages. I need to get the percentages off that Running Total (Grand Total).
    Am not sure how to acheive that either.
    Many thanks
    Regards
    Jehanzeb

  • Running Total and In Current Year Columns Source

    Hi all,
    What is the source for Running Total and In Current Year Columns from Absence Detail Screen.
    From Which tables can I get the information on those columns.
    Thanks in Advance

    Hello,
    I am still struck with Running Total Column
    When i fetch running total using this query it works for some of the employees
    SELECT SUM(ABSENCE_hours) from PER_ABSENCE_ATTENDANCES where person_id = <your person id> and absence_attendance_type_id = <your absence type id>
    As there are three different cases here as Days,Hours and No Balance
    I am missing the logic again here when it comes for no balance and days
    Thanks

  • Distinct Count Running Total

    <p>I have a report that gets a distinct count of items per day.</p><p>DistinctCount(, , "daily")</p><p> I would like to create a running total of the daily count for a weekly grand total.</p><p>Thanks!</p>

    <p>I&#39;ll take a stab at this - So I understand that the report is grouped by Day and looks like this:</p><p>GF1:    1/1/07   9</p> <p>GF1:    1/2/07   10</p> <p>GF1:    1/3/07   12</p> <p>GF1:    1/4/07   15</p> <p>GF1:    1/5/07   20</p><p> </p><p>The first thing I&#39;d try is to create a another group on your Date field, this time selecting the grouping option to be "For Each Week".  Take that group and move it so that it is Group1 and your current group is Group 2.... your structure will now look like this. </p><p>GH1:    1/1/07        < new &#39;week&#39; grouping&#39; > </p><p>    GF2:    1/1/07   9</p>  <p>    GF2:    1/2/07   10</p>  <p>    GF2:    1/3/07   12</p>  <p>    GF2:    1/4/07   15</p>  <p>    GF2:    1/5/07   20</p><p> Then I would copy the Sum field (distinct count) that you are using in Group 2 and put it in the Group 1 footer.  We could also create a formula to sum up all distinct counts per day, but a Distinct Count by week should accomplish what you are after.   Then in a seperate formula, you could divide the DistinctCount of orders (by week) by the DistinctCount of dates (by week) to get your daily average....</p><p>formula:</p><p>DistinctCount ({Orders.Order ID}, {Orders.Order Date}, "weekly") <br />/ <br />DistinctCount ({Orders.Order Date}, {Orders.Order Date}, "weekly") </p><p> </p><p>Hope that helps. </p>

  • Distinct count of GRN's in Query PLD

    hi all,
    We have developed a daily grn report and designed report
    using  Query PLD.
    Report contains
    (grn no,date,vendor name,vendor ref no,item code,item
    description,quanity & line total)
    We want to display no of grn's(distinct count)
    @ repetitive area footer.
    Is there any function available in formula field to display
    distinct count of no. of grn's ? / It should done thru query.
    Thanks,
    with regards,
    A.Jeyakanthan

    it will be hard from PLD, instead u can have ur query like,
    SELECT 'Details', '   ',T0.Docnum, T0.CardName, .... FROM OPDN T0 WHERE Month( T0.DocDate ) = Month ('{%0]')
    Union
    SELECT 'Counts', count(T0.DocNum) as 'Doc(s) No', ' ', ' ', ... FROM OPDN T0 WHERE Month( T0.DocDate ) = Month ('{%0]')
    (Replace { with [ )
    Note ' ' is a gap in order to fill the other fields. in first query have given tht '  ' gap purposely so tht the display will not affect ur designing part
    union is used b'coz Count() fn is like aggregate, so wont allow further individual fields coming along with it.
    the 2nd query will occupy only one row, which by grouping u can separate and can hide from repetitive and take the value via formula field by writing that field's id to it into Footer Area.
    Regards,
    Dhana.
    Edited by: Dhanalakshmi C on Mar 5, 2008 1:31 PM

  • Sql query to get distinct count

    Hi
    I use SQL Server Management Studio
    can I have a sql query to get count as shown below against  each month column and name column to get distinct count.
    for example if there is two rows with the same date period and same name then the count should be one in first row and zero in the next row of the same data.
    Table Name: Table1
    Column: Month, Name
    Month
    Name
    Count
    12/1/2012 0:00
    AK
    1
    12/1/2012 0:00
    AK
    0
    12/1/2012 0:00
    AB
    1
    1/1/2013 0:00
    AK
    1
    1/1/2013 0:00
    AK
    0
    1/1/2013 0:00
    AB
    1
    3/1/2013 0:00
    AA
    1
    3/1/2013 0:00
    AK
    1
    3/1/2013 0:00
    AK
    0
    6/1/2013 0:00
    AA
    1
    6/1/2013 0:00
    AK
    1
    6/1/2013 0:00
    AK
    0
    9/1/2013 0:00
    AA
    1
    9/1/2013 0:00
    AK
    1
    9/13/2013 0:00
    AK
    1
    10/1/2013 0:00
    AA
    1
    10/1/2013 0:00
    AK
    1
    10/1/2013 0:00
    AK
    0

    Hi,
    Thanks for the query but this query gives the total count like shown below
    if see the second row in the below table AK for 2012-12-1 gives total count as 2 but need the query to show the first row as 1 and there after 0
    query result
    Month name cnt
    2012-12-01 00:00:00.000 AB 1
    2012-12-01 00:00:00.000 AK 2
    2012-12-01 00:00:00.000 AK 2
    2013-01-01 00:00:00.000 AB 1
    2013-01-01 00:00:00.000 AK 2
    2013-01-01 00:00:00.000 AK 2
    2013-03-01 00:00:00.000 AA 1
    2013-03-01 00:00:00.000 AK 2
    2013-03-01 00:00:00.000 AK 2
    2013-06-01 00:00:00.000 AA 1
    2013-06-01 00:00:00.000 AK 2
    2013-06-01 00:00:00.000 AK 2
    2013-09-01 00:00:00.000 AA 1
    2013-09-01 00:00:00.000 AK 1
    2013-09-13 00:00:00.000 AK 1
    2013-10-01 00:00:00.000 AA 1
    2013-10-01 00:00:00.000 AK 2
    2013-10-01 00:00:00.000 AK 2

  • Query "Total Page Count"

    I have a HP Deskjet F4400 printer, I am running windows 7. I would like to get the "Total Page Count" from the printer. Is there a way to query this data from this printer?

    Post Author: V361
    CA Forum: General
    You could try creating a formula, for example
    WhilePrintingRecords;PageNofM
    and use the formula, hopefully, CR will be able to calculate the correct page count.

  • 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.

  • Running Total Variation Query Time Optimization

    Hi all, 
    I've been struggling with this query for a while. I need to set a customer specific running total for 10 million rows (reset for every customer). But every time the number goes negative, I need to set it as zero.
    For example,
    member no              amount            wallet
    member1                 400                      400
    member1                 -500                     0
    member1                  200                    200
    member2                  700                    700
    member2                 -200                    500
    Query:
    DECLARE @member float
    DECLARE @prev_member float
    DECLARE @amount float
    DECLARE @wallet float
    DECLARE db_cursor CURSOR FOR  
    SELECT [Member no], [Transaction Amount] 
    FROM [wallet_master_3]
    ORDER BY [Member No], [rownum]
    FOR UPDATE
    OPEN db_cursor
    FETCH NEXT FROM db_cursor INTO @member, @amount
    SET @prev_member = @member
    set @wallet=0
    WHILE @@FETCH_STATUS = 0
    BEGIN   
           IF @prev_member <> @member set @wallet=0
           SET @wallet = @wallet + @amount
           IF @wallet < 0 SET @wallet = 0
           UPDATE [wallet_master_3] SET walletsize = @wallet
           WHERE CURRENT OF db_cursor
           set @prev_member=@member
           FETCH NEXT FROM db_cursor INTO @member, @amount
    END   
    CLOSE db_cursor   
    DEALLOCATE db_cursor
    I've tried using a cursor. In five minutes, it ran 17,000 rows but after running it for 15 hours, the code only manages to set the running total for 175,000 rows. I'm not exactly sure why. Is there a faster approach I can use? 
    Thanks!

    As an exercise a 'Quirky Update' may help you in this scenario. Try the below trick!
    DECLARE @Wallet AS TABLE
    MemberNo VARCHAR(10),
    RowNum INT,
    Amount INT,
    Wallet INT
    INSERT INTO @Wallet (MemberNo, RowNum, Amount) VALUES
    ('member1',1, 400),
    ('member1',2, -500),
    ('member1',3, 200),
    ('member2',1, 700),
    ('member2',2, -200)
    DECLARE @RunTotal AS INT
    UPDATE W1
    SET
    @RunTotal = W1.Wallet =
    CASE
    WHEN W1.RowNum = 1 THEN W1.Amount
    WHEN @RunTotal + COALESCE(W1.Amount, W2.Amount) < 0 THEN 0
    ELSE @RunTotal + COALESCE(W1.Amount, W2.Amount)
    END
    FROM @Wallet W1
    LEFT OUTER JOIN @Wallet W2
    ON W1.MemberNo = W2.MemberNo AND W2.RowNum = W1.RowNum - 1;
    SELECT * FROM @Wallet;
    RESULT
    MemberNo RowNum Amount Wallet
    member1 1 400 400
    member1 2 -500 0
    member1 3 200 200
    member2 1 700 700
    member2 2 -200 500
    You can read more on 'Quirky Update' in below articles
    Solving the Running Total and Ordinal Rank Problems - Jeff Moden
    Robyn Page's SQL Server Cursor Workbench
    NOTE: Please test it thoroughly before using in a production environment!
    Krishnakumar S

  • Displaying Distinct Count as Grand Total

    Hi -
    I have a requirement where i have to show the distinct count of Transaction Numbers at the bottom of the report as Grand Total. I created a dummy column with Fx as MAX(RCOUNT(1)) and used it in Narrative view and it is showing me the total rowcount whereas i want the distinct rowcount based on Transaction number column in my report.
    Any help is appreciated!
    Thanks
    R

    Instead of using a RCOUNT you can use the COUNT(DISTINCT <Transaction Number Column>) in your column formula
    This is an inbuilt function.
    Mark if it helps..

  • Totals for Count Distinct

    I need to display totals for Count Distinct measures. I want to display these above a table view.
    We have done this before by creating hidden columns with level-based measures for totals and then displaying the first row of these hidden columns in a narrative view above the table. We have also used MAX(RSUM()) within requests, sometimes.
    These solutions won't work, because I need Count Distinct() measures (so simple sums and counts will give inaccurate results) and I may navigate to the request with filters at different levels (so LBMs won't work, either).
    The only solution I can think of is to have LBMs for each level and have duplicate dashboards that differ only in which variation of this request with which level's LBMs are displayed for the totals. That seems like too much of a kluge. There should be a simpler, better way to do this.

    I was trying to reproduce your issue with "Sample Sales" - but can't figure out which columns you'd like to see. Can you please post couple columns - and which count distinct you need? That would make it easier to reproduce the issue.
    I was thinking that it might be difficult to pull it in 1 report (since you can't completely exclude columns in table view). I have two suggestions:
    a) did you try to create a separate report and combine it with existing one (same Dashboard page)?
    b) did you try Pivot Table and its calculated column feature? I've had some success with it when I needed to combine measures at different levels on the same report (i needed to see daily totals for 3 specific days, monthly values for specific months, and couple annual totals). This way you could have it on the same report.
    I just tried A. And it worked (again, not sure if this is applicable to your situation). I used "Server Complex Aggregate" in column options. The formula is showing: SELECT "D5 Employee"."E01 Employee Name" saw_0, COUNT(DISTINCT "D1 Customer"."C1 Cust Name") saw_1 FROM "Sample Sales" ORDER BY saw_0
    Edited by: wildmight on Oct 30, 2009 9:35 AM

  • DAX query to calculate distinct count respect to a column after a Filter function - SSAS 2012 Tabular

    Hi,
    I'm trying to build the dax query to determine the distinct count for a column returned by the application of a Filter function.
    evaluate(
    row("counter",
    countrows(
    filter(order_summary,
    year(order_summary[change_date]) = 2013) )
    I need to count the distinct values for an id returned by the Filter function.
    Any helps, please? Thanks

    Hi pscorca,
    According to your description, you want to calculate the distinct values for records where change_date is 2013. Right?
    In this scenario, we can use the DISTINCT() function within COUNTROWS(). Please try the expression below:
    =calculate(
    countrows(distinct(order_summary[column])),
    Filter('order_summary', year(order_summary[change_date])=2013)
    Reference:
    Distinct Count Measure in PowerPivot using DAX
    Related Distinct Count
    Best Regards,
    Simon Hou
    TechNet Community Support

Maybe you are looking for

  • Issue in seperating lines of ITAB and placing into SF secondary  windows

    Great abapers, My itab is having 6 lines item (for ex ) it may 'n' no of line items. In smartforms for 1 page max allowed secondary window is 2.so first 2 lines are paced in first page , next 2 lines are place in second page ,last 2 will be in 3 page

  • Sync Smart Albums

    I have Mac with 10.5.7 and iTunes 8.2.1. I am trying to sync both my iPhone 3.0 and my iPod with my MacBook Pro. Most of my smart albums sync but others remain blank on either of my devices. I have tried manually syncing and auto syncing and the same

  • Oracle 11g X64 installation help

    iam trying to install oracle 11g for x64 on a 64-bit fedora 11 system i have configured all the required pre-requisites properly, after providing password , global database name etc..the installer stops at 91 % , i.e even before the actual installati

  • InDesign 2014 installation error on Windows7 32bit

    Trying to install inDesign 2014 on Windows7 32bit. It stops the process saying "Error: impossible to extract in the temporary directory (EX11)" what's the matter? Thank you very much, Nicola.

  • Alternating row colors inside netui-data:repeater?

    Is there an easy way to make the row colors alternate inside the netui-data:repeater? I am looking for somthing similar to what happens with the netui-data:grid tag. A code sample maybe? Thanks, John