Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: How to format a number field in Crystal Report XI Post Reply Post New Topic
Author Message
dhanashivam
Newbie
Newbie
Avatar

Joined: 07 Aug 2008
Location: India
Online Status: Offline
Posts: 2
Quote dhanashivam Replybullet Topic: How to format a number field in Crystal Report XI
     Posted: 07 Aug 2008 at 4:06am
Dear All,
I am using Crystal Report XI Relase 2 in my asp.net web app. I would like to format the number field which is used in summary functions like "SUM".

I opened the Crystal Report and set the Thousand separator and Decimal Separator. But I need to give the Group Seperator.

In a site I found that the following can be used. 

ToText ({P_ADJUSTMENTS.AMOUNT_DEFAULT}, "##,##,###.##", 2, ",", ".")

Its working fine.  But the number is becoming as text and i am facing some other problems in my logics.

So anybody can please tell me whether any other solution for this.

thanks in advance.

dhana.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 09 Aug 2008 at 4:31pm
Yes, the "ToText" function returns text because you are changing how the output of a number looks. You are not changing the internal storage mechanism of the number. In fact, how a number is stored internally is irrelavant. The ToText() function should only be used to print a number on the report, not for internal calculations prior to it being printed. Thus, I don't understand why you need to care about the thousand separator if you're just using the numer in another calculation.
 
The only thing I can possibly think of is that you're exporting this to Excel and Excel is reading it as a text field and then you can do calculations on it in your spreadsheet. If that is the case. you can change the number formatting for a field on the report to use different separators, and that way it stays in a numeric format without having to call the ToText() formula.
 
I hope this helps.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
dhanashivam
Newbie
Newbie
Avatar

Joined: 07 Aug 2008
Location: India
Online Status: Offline
Posts: 2
Quote dhanashivam Replybullet Posted: 12 Aug 2008 at 9:58pm
thanks for your reply.
 
i used the ToText function for display purpose. and created another for number based actions such as sum.
 
now i am getting a new problem. i have written the following.
 
Totext(myField,"##,###,##,##,##0.00",2,",",".")
 
myField value is "-325.85". it gives the output as "-       325.85".
 
that is with leading white spaces. i need to remove the white spaces without doing any additional replace process.
 
so please suggest me how to do it.
 
thanks in advance.
 
dhana.
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 13 Aug 2008 at 4:49am
Hi,
 
Use the code below
 
replace(Totext(-325.85,"##,###,##,##,##0.00",2,",","."),' ','')
 
use myfield instead of -325.85
 
Cheers
Rahul
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum