Search code examples
c#ado.netcrystal-reports-2010sql-view

Display a field if it's different than 0, else don't display it - in a Crystal Reports formula


For one double field in Crystal Reports, I wish to write up formula where if that field is equal to zero, it should display as "--", else the actual value should be shown.

What I have written is :

If (IsNull({View_journal.debit})) then  
    "--"
Else {View_journal.debit}

but the formula doesn't execute at all.


Solution

  • null is not the same as 0. Your formula should be something like

    if 
       {View_journal.debit} = 0 
    then
        "--"
    else 
        ToText({View_journal.debit}, 2)
    

    EDIT: ToText converts debit value to string with 2 decimal places.