CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2010
    Posts
    6

    Unhappy count or percentage of fields with value... in a colomb.

    I am searching for a formula (in crystal reports 8.5)
    - to count the fields in a colomb {JobRecStatus} which value is equal to 4.
    - to calculated the percentage fields in a colomb {JobRecStatus} which value is equal to 4.
    (all the fields in this colomb are 100%) how many fields are "4".

  2. #2
    Join Date
    Jul 2005
    Posts
    1,083

    Re: count or percentage of fields with value... in a colomb.

    Three Formulas

    1. In Report Footer section, to count all the rows
    2. In Detail section to count only the rows in wich the field is = to 4
    3. In Report footer section to calculate the percentage of rows in wich the field value is = 4

    It's good time to learn
    Last edited by jggtz; February 16th, 2010 at 07:06 PM.

  3. #3
    Join Date
    Feb 2010
    Posts
    6

    Re: count or percentage of fields with value... in a colomb.

    How do these formulas (2 and 3) look like?

  4. #4
    Join Date
    Jul 2005
    Posts
    1,083

    Re: count or percentage of fields with value... in a colomb.

    1. Insert a Summary field Counting the field {TableName.JobRecStatus}
    Place it in Report Footer (well it place by itself)
    Format Field / Suppress

    2. Insert a new Formula field
    Let's call it MyCounter
    Place it in Detail Section
    Format Field / Suppress
    I'm assuming that JobRecStatus is a string type field
    If it's numeric then remove Trim() function and change to 4 instead of "4"
    Code:
    WhilePrintingRecords;
    numberVar Counter ;
    If Trim({TableName.JobRecStatus})= "4" Then Counter := Counter +1;
    Counter;
    3. Insert a new Formula field
    Let's call it MyPercent
    Place it in Report Footer Section
    Code:
    WhilePrintingRecords;
    numberVar PerCent;
    Percent := {@MyCounter} * 100 / Count ({TableName.JobRecStatus});
    PerCent;
    Just change TableName by your table's name

    JG
    Last edited by jggtz; February 16th, 2010 at 07:04 PM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured