Ali Sheikh
Ali Sheikh

Reputation: 45

Crystal Report Formula to show records where specific field not null?

I am using SQL Joins to retrieve data from multiple tables. I am grouping records by department. I want to show only those records where Department Name not null. I can control this through JOINS but in some other scenarios I need to show null department records. Is there any formula to make it possible? My current formula is:

if {?ParamGrp} = "Department" then
(
  "Department Name:  " &{tblEmployees.DepartmentName}
)
else if {?ParamGrp} = "" then
(
  ""
)

Upvotes: 1

Views: 1631

Answers (1)

4444
4444

Reputation: 3680

Crystal has a built in formula ISNULL() for situations where a value is literally null, and not just an empty string. You can splice it into your existing code easily:

IF ISNULL({tblEmployees.DepartmentName}) OR {?ParamGrp} = "" THEN
    ""
ELSE IF {?ParamGrp} = "Department" THEN
    "Department Name:  " & {tblEmployees.DepartmentName}

Upvotes: 1

Related Questions