Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Group formula

Status
Not open for further replies.

swiss2007

Technical User
Aug 13, 2007
92
US
I have my data something like this


England (GROUP)
emp Customername Order date payment received
id
1 BBS Pty 09-Feb-2004 True
1 BBS Pty 01-Mar-2004 True
1 BBS Pty 24-Oct-2004 True
1 BBS Pty 18-Apr-2005 False
3 BBS Pty 30-Mar-2004 True
3 BBS Pty 14-Apr-2004 True
3 BBS Pty 21-Jul-2004 True
3 BBS Pty 15-Oct-2004 True
3 BBS Pty 19-Apr-2005 False
3 McDonald
Klein Sports 17-Jun-2004 True
3 Picadilly Cycle 19-Jun-2004 True
3 Source One Cycle 17-Jun-2004 True
4 BBS Pty 03-Dec-2003 True
4 BBS Pty 30-Dec-2003 True
4 BBS Pty 21-Feb-2004 True
4 BBS Pty 25-Jun-2004 True
4 BBS Pty 27-Oct-2004 True
4 BBS Pty 25-Nov-2004 True
4 BBS Pty 09-Dec-2004 True
4 Great Outdoors 19-Jun-2004 True
4 Wheel to Wheel 17-Jun-2004 True
6 BBS Pty 05-Jan-2004 True
6 BBS Pty 20-May-2004 True
6 BBS Pty 03-Sep-2004 True
6 BBS Pty 17-Mar-2005 True
6 BBS Pty 18-Apr-2005 False
6 Exeter Cycle Source 19-Jun-2004 True
6 Sunrise Cycle 17-Jun-2004 True
6 Westerly Sports 18-Jun-2004 True
7 BBS Pty 22-Dec-2003 True
7 BBS Pty 02-Jan-2004 True
7 BBS Pty 21-Oct-2004 True
7 Tom's Bikes 17-Jun-2004 True
9 BBS Pty 19-Jun-2004 True
9 BBS Pty 14-Jan-2005 True
9 Donview Bike Co. 18-Jun-2004 True
9 Hit the Dirt 18-Jun-2004 True
9 Life Cycle Centre 19-Jun-2004 True
9 LifeCycle 18-Jun-2004 True

Is there a way I can display the customer name in Group Header or Group Footer based on the following condition

if payment received = true get the customer name where empid = 7 for the order date = minimum
else if payment received = false get the customer name where empid = 7 for the order date = maximum
else ''

I have this report as one of the subreports.
Can a running Total be used on the string fields.

Thanks in Advance,your help is appreciated.
 
You should be able to do it with a running total, results to be shown in the footer.

Running totals will count the occurances of string fields, or find the maximum or minimum. Also anything can be used as a running total selection formula.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
There is a difference between asking for the minimum date of that set of dates where payment received = false and asking for the minimum date of all transactions if the payment received = false. I'm guessing you really mean the first.

Also, do you really want just one or the other or do you want both names (when they both exist)?

And, can date and payment received be null? If so, what would you want to see?

It might help to see what you'd like as results for the above sample.

-LB
 
I don`t want both names,I want only one name.Payment received could be null, but not the date.I require minimum date of the set of dates where payment received = false

Thanks for your replies
 
Insert a sescond group on empID. Then create two formulas:

//{@falsedate}:
if isnull({table.paymentreceived}) or
{table.paymentreceived} = False then
{table.orderdate}

//{@truedate}:
if {table.paymentreceived} = True then
{table.orderdate}

Then create this formula:

//{@accum}:
whileprintingrecords;
stringvar custname;
if {table.empID} = 7 then(
if minimum({@truedate},{table.empID}) <> date(0,0,0) and
{table.orderdate} = minimum({@truedate},{table.empID}) then
custname := {table.custname}
) else
if (
maximum({@falsedate},{table.empID}) <> date(0,0,0) and
{table.orderdate} = maximum({@falsedate},{table.empID}) then
custname := {table.custname}
);

Then in the group footer, use this formula:
//{@display}:
whileprintingrecords;
stringvar custname;

If you are not linking the sub on the country group, you would also need a reset formula in the group header:

//{@reset}:
whileprintingrecords;
stringvar custname;
if not inrepeatedgroupheader then
custname := "";

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top