views:

303

answers:

5

How can i format quantity value in crystal report like if the value is 5, then just show as 5. If the value is 5.25, then show as 5.25. So which format should i use for that?

Thanks.

A: 

Right-click on the element and go into the formatting menu. I think what you want will be an option.

John at CashCommons
No, I already tested the Default Custom Format in Report. If i choose, ".00" then it ever show "5.00" though the value is 5.
nwaynge
A: 

Now i got with this formula : if {@test} - truncate({@test}) <> 0 then 1 else 0

But i can't get the decimal value coz of rounding number.
My values in the table are :
5
6.25

With using this formula : it shows
5
6.00

Help me please

nwaynge
A: 

Instead of displaying it as a numeric value, write a function, MyStr$, which converts to string depending on whether the number is integer or not. BTW, a good way to check for integrality is a test of the form:

ABS(x -Truncate(x)) < EPS

where EPS is a small value, like 0.001 (depending on the accuracy you need, increase or decrease this)

Constantine
A: 

Use this "conditional format formula":

If Truncate(CurrentFieldValue) = CurrentFieldValue
    Then
        0
    Else
        Length(ToText(ToNumber(StrReverse(ToText(Abs(CurrentFieldValue) - Truncate(Abs(CurrentFieldValue)),8,"",""))) / 10,0,""))

Go to the numeric report field, rightclick, choose "Format Field", choose "Number" tab, click "Customize" button. Put the formula above in the format formula ("X+2" button) for the format options "Decimals" and "Rounding".

BTW: In the formula you'll notice the number 8. This is the maximum expected number of decimals; if you think you'll encounter more decimals in your report then simply change 8 to a higher number.

A: 

Hi Mac!

the formula did not work for me and is showing all the data as whole numbers not in decimals.

Saqi