Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Blank space if value = 0 2

Status
Not open for further replies.

ksbigfoot

Programmer
Apr 15, 2002
856
CA
I am using Crystal 10.
I have a group header that has only two options (sweet, sour).
There is a field called (GOR) in my detail section, it is a numbered field.
In the SOUR group, I want the value for GOR to show up even if it is zero.
In the SWEET group, If the value of GOR is zero or NULL, I want a blank space to show up instead of displaying 0.

Could someone point me in the right direction on how to do this.
Thanks
 
you can create a Gor Formula for both groups and place it in the detail section.

if ({GOR}) = null then 0

if ({GOR}) = null then ""


or if isnull({GOR})
 
Use IsNull(), IF, and Cstr() functions to return a blank string or the number formatted as string depending on the condition.

Cheers,
- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
When I try to put a string in the field in the formula, it says that 'a number is required here' and highlights the ""

Code:
If NOT IsNull({v_PropertyWellList.GOR}) Then
  {v_PropertyWellList.GOR}
Else
  ""

My field is a number because I format for decimal places.
 
You can use the CSTR() to convert your numbers

CStr({v_PropertyWellList.GOR})



 
Try:

If not(IsNull({v_PropertyWellList.GOR})) Then
totext({v_PropertyWellList.GOR},0,"")
Else
""

-k
 
Thanks for the posts.
If I convert to string, how do I format my string to not have a comma at the thousands separater and limited to one decimal place with rounding?
Ex.) 1,098.26 --> 1098.3
 
Note that I used totext with the parameters passed to supply no thousands indicator and 0 decimal places, cstr works the same way, so adjust it to 1.

I would also suggest getting in the habit of wrapping NOT in parentheses as it can confuse Crystal when using more advanced formulas.

-k
 
Hi IdoMillet,
I tried the way you said and I am getting the thousand separator in the number still.

Here's my code
cstr({v_PropertyWellList.GOR},1)

Here is the result I am getting:
1,803.2
I would like 1803.2
Thanks
 
I just used the replace function and it removed the comma from my string.
Thanks again. :>
 
Just use:

If not(IsNull({v_PropertyWellList.GOR})) Then
totext({v_PropertyWellList.GOR},1,"")
Else
""

-k
 
Hi synapsevampire,
Works like a charm. Thanks.
Do you know of a good book or tutorial that will show how to learn these functions?
Thanks
ksbigfoot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top