I have a field in my Crystal Report that can either contain a whole number, or a number with a decimal. How do I make it so it doesn't display .00 after a whole number, but will still show decimals when applicable? Mike,
There are a couple of ways I can think of, though one has drawbacks:
1- If you're building the report data from a dataset, you could use a string field, and do the parsing and converting from there, so that the string columns contains what you want to display. Drawback is that you probably wouldn't be able to create a subtotal in Crystal on that column (at least not easily).
2- In Crystal, for numeric columns, there is the decmial format option, which you can configure at runtime for every row with a formula. You might want to try writing a formula that compares the current value to the value rounded to zero decimals. If they're equal (e.g. 162.00 = 162), you return a 0 that CR will use for # of decimals for that row. If they're not equal (e.g. 162.13 <> 162), then return a 2.
I'd check first to make sure Crystal doesn't already have a math formatting function that would handle this (I just did a quick glance and didn't see anything). If it doesn't, I'd try #2. (Obviously, test the results, I've never specificially tried what I've described in #2, but I believe it should work).
Hope that helps...
Kevin