Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2007
    Posts
    3

    Unanswered: Crystal Reports Help

    I'm fairly new to crystal reports, and I'm in desperate need of some help. I'm trying to count the number of times an instance appears in a row. For instance I'm trying to count the number of times the string "fail" appears in the row, but I can't seem to figure it out. If anyone could responsed with a couple of coding ideas I'd appreciate it. Thanks a lot!

  2. #2
    Join Date
    Feb 2007
    Posts
    348
    Matt,
    I'm in Crystal 10. I would add the field I want to count to the details, then I would create a new running total field. I would tell it which field I was counting. Under the evaluate section of the Running Total Expert I would select Use Formula. For the formula, it should just be something like "Fail" and nothing else. Then run it and see if it goes.

  3. #3
    Join Date
    Jul 2007
    Posts
    3
    I'm not sure I understand what you mean. The code that I think should work is this:

    Code:
    local numbervar Index;
    local numberVar totalPassed := length ({@Passed});
    local numberVar totalLength := count({@Passed});
    
    for Index := 1 to totalPassed step 1 do
    
    (if ({@Passed} [Index] = "Passed") Then
    
    (totalLength := totalLength;)
    
    else 
    
    (totalLength := totalLength -1 ;)
    
    );
    
    totalLength
    So I think it will loop through the column and for every instance of a "Passed" it will delete one from the count and then display the count at the end. But for some reason it isn't working, instead of the right answer it gives me a strange number that isn't the count or the number of "Passed" in the column. Any insight would be extremely helpful.
    Last edited by ThrowerMatt; 07-06-07 at 12:56.

  4. #4
    Join Date
    Feb 2007
    Posts
    348
    See if the PDF attached makes more sense.
    Attached Files Attached Files

  5. #5
    Join Date
    Jul 2007
    Posts
    3
    THANKS!!!!!!!!!!!!!!!!!!!!! That worked perfectly, thank you so much.

  6. #6
    Join Date
    Feb 2007
    Posts
    348
    glad to be of service.

  7. #7
    Join Date
    Jul 2007
    Posts
    54
    I like Starkmann's solution, but my instinct is to try something simpler:

    Another solution you could try is to create a formula which you insert on the detail line which says something like:

    if <fieldname> = "fail" then 1 else 0

    Next insert a total on that field at group or grand total level and there is your result. Now you can put some pretty text around it and suppress the formula above on the details line.

    Cheers,
    Caspar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •