supress zero rows in crosstab crystal reports

2019-08-27 22:59发布

问题:

I have crosstab looks like this

          Jan           Feb
Emp1      500           600
Emp2      600           700
Emp3       0             0

I want to hide the row3 as it has zero values. I have seen in crosstab expret to supress empty rows but that doesn't server the purpose. I want output like this

          Jan           Feb
Emp1      500           600
Emp2      600           700

回答1:

Create a SQL Expression that returns a NULL:

-- {@DB_NULL}
-- Oracle syntax
(
SELECT NULL FROM DUAL
)

-- {@DB_NULL}
-- MS SQL syntax
(
SELECT NULL
)

Create a formula field to convert 0 to NULL:

-- {@data}
If {table.field}=0 Then
  {@DB_NULL}
Else
  {table.field}

Reference this field in your cross-tab instead of {table.field}. You may have to reset the 'suppress empty rows' setting.