Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Sort Formula Field Post Reply Post New Topic
<< Prev  Page  of 2
Author Message
ridershaun
Newbie
Newbie


Joined: 31 Aug 2010
Online Status: Offline
Posts: 32
Quote ridershaun Replybullet Posted: 03 Feb 2015 at 4:05am
I'm grouping on order type which is using the following formula:
global stringvar ordertype;
IF {PO.LOCATION} like "??P??" THEN 'AUTO'
ELSE IF {POLINESRC.REQ_LOCATION} like "??X??" THEN 'SCAN'
ELSE 'OTHER';
---------------------------------------------------------
---------------------------------------------------------
The formula I'm using to get the Qty Var is '{@OneMoQtyTotDisplay} - {@avg3moqty}'
---------------------------------------------------------
The formula for {@OneMoQtyTotDisplay} is:

WhilePrintingRecords;
Global NumberVar OneMoQtyTotByItem;

{PO.ITEM};

OneMoQtyTotByItem;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is using the other following formula's.
---------------------------------------------------------
This is placed in the details:

WhilePrintingRecords;
EvaluateAfter({@onemonthqty});

Global NumberVar OneMoQtyTotByItem;
Global NumberVar onemonthqty;

{PO.ITEM};

OneMoQtyTotByItem := OneMoQtyTotByItem + onemonthqty;

OneMoQtyTotByItem;

--------------------------------------------------------
Reset placed in group header:

WhilePrintingRecords;
//EvaluateAfter({@OneMoQtyTotDisplay});

Global NumberVar OneMoQtyTotByItem;

{POLINE.ITEM};

OneMoQtyTotByItem := 0;
---------------------------------------------------------
The {@avg3moqty} formula is 'Sum ({PO.QUANTITY}, {PO.ITEM})/3'




I hope this helps. Thanks
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Feb 2015 at 4:32am
Not seeing your detail level data I am not sure if there is a way to get the sorting the way you want without using a calculation method that gets teh values before getting it into Crystal, meaning you may want to look at using a command or stored proc to get your group sort value at the same time it fetches all of the data. You can just sort on that field then.
The group sorting happens in a report pass that precedes where you are doing these whileprintingrecord calculations.
Also, occasionally you can use a different group summary calculation that gets a value that alwasy gives you the 'correct' sort order values and you can use that as the sort value without actually displaying it.


Edited by DBlank - 03 Feb 2015 at 4:34am
IP IP Logged
Vimal Nair
Newbie
Newbie
Avatar

Joined: 29 Dec 2014
Location: United Arab Emirates
Online Status: Offline
Posts: 26
Quote Vimal Nair Replybullet Posted: 03 Feb 2015 at 6:57pm
So the group is on Order Type. As DBlank told, I prefer to use a command or Proc for this. DO all the calculations at query level and pull the data to the report. Then its very easy to do sorting in report.


I Assume that you are displaying
SCAN

In Group Header

And the below fields in Details.

40555     5        6     1
40557     8        4     -4
12124     4        8     4

If its the above case, put a record sort on Var formula.

In another case if you have created another group for
Item also and displaying this on header, you have to bypass the group sorting.

Create a Summary for the field to be sorted and put it on Group Footer. Supress the Group Footer. Then on Group Sort Expert add that summary which is pulled in to the group footer. Also put a dummy formula in Group expert for sorting.This will bypass the group sorting.
Born To Live
IP IP Logged
<< Prev  Page  of 2
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