barsan
barsan

Reputation: 2491

How to return zero for a field in Crystal report

I am generating crystal report from database. My requirement is to when the field TKK Balance returns 0 or more than 0 for a row the report will print a dash '-' for that row and if it is less than 0 then only it will return the original value from the database. Is there anyone who can help me on this? please? Thank you

Upvotes: 0

Views: 860

Answers (1)

David -
David -

Reputation: 2031

First of all it can be done inside the SQL select statement like this

,(
    CASE WHEN [TKKBalance] >= 0
        THEN '-'
        ELSE CONVERT(NVARCHAR, [TKKBalance])
    END
) AS [SomeName]

or, you can create and use a formula field inside your report with the following code

if {TableName.TKKBalance} >= 0 then
    "-"
else
    totext({TableName.TKKBalance})

Upvotes: 1

Related Questions