cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove decimals and round it off as a whole

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

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;

Former Member
0 Kudos

The first part of the formula should have dealt with that

ToText(ItemNumber, 0,"")

Ian
Former Member
0 Kudos

But it all became 0, without incrementing 😞

Former Member
0 Kudos

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

Former Member
0 Kudos

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?

Former Member
0 Kudos

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

Answers (0)