Skip to Content
0

How to remove decimals and round it off as a whole

Apr 13 at 01:37 AM

43

avatar image

Hi Team

Basically, I have 2 formula fields in my details section.

I want them to be displayed as a whole number without decimal places.

How can I get rid of the decimal place? Do I have to edit it in a formula and out round () formula?

My formula on the @Details is:

WhilePrintingRecords; NumberVar ItemCount := ItemCount + 1;

My formula on @LineCount is:

WhilePrintingRecords; NumberVar ItemNumber; CStr(ItemNumber, "0") & "/" & CStr(Count({rpt_PackingSlip.LabelQTY}, {rpt_PackingSlip.WorkOrderNo}))

Please assist.

capture.jpg (79.6 kB)
capture1.jpg (24.4 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Ian Waterman Apr 13 at 08:14 AM
0

Never used cstr I always use totext() and that will achieve what you want

ToText(ItemNumber, 0) & "/" & ToText(Count({rpt_PackingSlip.LabelQTY}, {rpt_PackingSlip.WorkOrderNo}),0)

If you numbers are likely to exceed 1000 and you do not want , thousand separator

ToText(ItemNumber, 0,"") & "/" & ToText(Count({rpt_PackingSlip.LabelQTY}, {rpt_PackingSlip.WorkOrderNo}),0,"")

Ian

Show 6 Share
10 |10000 characters needed characters left characters exceeded

Thanks Ian.

That really works! Now I am able to apply TOText formula on my @LineCount formula.But how about @Details?

How can I remove the decimal and round it off?

Here's what happened and my code:

You would notice that it is still 1.00/5

WhilePrintingRecords;
NumberVar ItemCount := ItemCount + 1;

details.jpg (26.1 kB)
0

The first part of the formula should have dealt with that

ToText(ItemNumber, 0,"")

Ian
0

But it all became 0, without incrementing :(

comments.jpg (13.6 kB)
comments2.jpg (26.6 kB)
0

It could be a timing issue. Split details into two sections, place the @DEtails formula in top section and suppress that detail section in section expert

Ian

0

Thanks Ian.

Now the issue is the Count of orders PER line item.

I have a set of data in Crystal reports that looks like below: You can see that each item, they have corresponding quantity.

However, there are no suppressed details in the report then the line-number should be equal to RecordNumber. So the following formula I got from you is:

WhilePrintingRecords;
NumberVar ItemNumber;
ToText(ItemNumber, 0) & "/" & ToText(Count({rpt_PackingSlip.LineNo}, {rpt_PackingSlip.WorkOrderNo}),0)

which resulted to:

Notice that it sums all the records in 1 SalesOrder.

But my desired output is:

Abbey should be 1/1

Charlotte should be 1/1

Do you have an idea on what are did I get it wrong?

0

In your example you have Sales order which is same for both Abbey & charlotte. Is salesorder same as

rpt_PackingSlip.WorkOrderNo

If you want to count on Description you will have to add another group based on Description field, add this below WorkOrderNo Field, suppress header and footer. Change your formula to

ToText(Count({rpt_PackingSlip.LineNo}, {yourdescriptiongroupfield}),0)

Ian

0