Crystal Reports Multiple if conditions in Record Selection

Sameera Silva picture Sameera Silva · Jan 29, 2014 · Viewed 20.5k times · Source

I want to create a report and filter it by two parameters as below;

Parameter values are;

Call_type = "All" , "Sale" , "Buy"
and
Call_status = "All" , "Sold" , "Pending" , "None" , "Closed"

I have used below formula;

(
if {?type} <> "All" then
    {cars_call_log.type} = {?type}
else
    true;
);
(
if {?status} <> "All" then
    {cars_call_log.status} = {?status}
else
    true;
);

But it will work only for first If condition. It doesn't work for both conditions.

I want to make it like, Filter by first parameter then (filtered records)--> filter by second parameter.

Answer

craig picture craig · Jan 29, 2014

The proper, record-selection-formula syntax for your needs:

(
if {?type} <> "All" then
  {cars_call_log.type} = {?type}
else
  true
)
AND
(
if {?status} <> "All" then
  {cars_call_log.status} = {?status}
else
  true
)