Search code examples
crystal-reports

Is there a way to filter one database field based on another?


I have one field which is {customer.id} and another which is {side} (that has the values "L" and "R") and I need to count the {customer.id} if {side} is either "L" or "R" but not both(xor) for the specific id. Example:

{customer.id}     {side}
   id1              L
   id1              R
   id2              L
   id2              R
   id3              L
   id4              R 
   id4              R

So I would like the result of the distinctcount for this example to be 2 (id3 and id4).

Is it possible to achieve this filtering somehow in crystal reports?


Solution

  • Create two running totals for "L" and "R"

    • Fields to summarize: {customer.id}
    • Type of Summary: Count
    • Evaluate: Check Use a Formula and press the formula button.
    • In the formula box enter {side} = "L"
    • Reset: Check Never

    as seen here.