Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formating Post Reply Post New Topic
Author Message
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Topic: Formating
     Posted: 05 Apr 2015 at 1:39am
I have a text string that includes a SUM calculation.
It works fine except I get decimal places in the sum field which I do not want - if I use 'totext' function to try to remove the decimal places I get this error:
"A group condition is not allowed here" I know I can split it up but would prefer to keep it together as one string of text.
Any help much apprecited.
brockloch
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 06 Apr 2015 at 10:04am
Have you tried formatting the integer field to not show decimals?

Right click > Format field > select a number format without decimals or move the decimal place to 0
IP IP Logged
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Posted: 06 Apr 2015 at 10:35pm
Hi
The problem occurs when I add the sum to a string llike below:

"Also comprises: "&Sum ({hylDespItem.DiItmQty}, {STOCK.UNIT_OF_SALE})&"items."

- this becomes; "Also comprises 25.00 items", when I want it to read "Also comprises 25 items"

And I can't seem to format it when it is in the string.
Any help appreciated.
brockloch
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 07 Apr 2015 at 2:20am
Look up the function

ToText(x,y)

The (x) will be a number or currency you want converted to text.
The (y) will indicate the number of decimal places to carry from the x value.

Something like:
"Also comprises: " & ToText(Sum({{hylDespItem.DiItmQty}, {STOCK.UNIT_OF_SALE}),0) & "items"
IP IP Logged
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Posted: 07 Apr 2015 at 3:20am
Thanks for the quick response but this format caused the initial error message.
brockloch
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 07 Apr 2015 at 4:00am
Did you add the (y) value to the ToText function?

It removed the decimal points in my test.
Note that I accidentally typed an extra { in the sum field.

Maybe someone else has another suggestion.
IP IP Logged
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Posted: 08 Apr 2015 at 11:08pm
Thanks for all your help, I will go back to the start and try again, thanks again.
brockloch
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Apr 2015 at 3:51am
adavis is giving you a solid answer that should work.
You can also
create a text field
type in the free text
insert a group summary as a Sum of DiItmQty
drag and drop this group sum field into the text field where you want it
right click on the summary field inside the text field and select 'Format Text'
select the number format you want
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