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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Previous() on a groupname

Status
Not open for further replies.

Budjette

Programmer
Jul 8, 2002
29
0
0
CA
Hi!

Is it possible to create a formula that returns the previous groupname of a group. Example: I group my report by invoices (each invoice have lots of details). I want to compare the current group with the previous group. Is this possible? Or can I just compare the current record with the previous record?

Thanks in advance,

Budjette
 
The Previous and Next functions only work on the record level for the previous and next records.
You can compare Group fields when the group changes, but you would already know that because the Group Header would print again.

If you need to compare fields in different groups, you would need to save values in variables in one formula and then do your comparison in a seperate formula.

Explain more about what you need to accomplish, provide some data, and someone here can give you the best approach to solving your problem.


~Brian
 
It all depends on when you need the "previous" value.

Previous() works on a database field rather than Groupname.
Rather than looking at the Groupname look at the database field that the group is based on.

if you use a formula in the group header the previous() will refer to the previous group since the header operates on the first record of a group...so previous looks at the last value of the previous group.

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
You might try inserting a crosstab, using {table.invoiceID} as a column, {table.customerID} as the row, and sum({table.amount}) for the summary field. This would provide a visual comparison.

If by "compare" you mean you want to do calculations on the summary fields then you might try a manual crosstab. You would group on customer and then create formulas like:

{@col1}:
if {table.invoiceID} = 123 then {table.amount}

{@col2}
if {table.invoiceID} = 456 then {table.amount}

Then you would insert summaries on these at the group level and suppress the details. Let's say you then want to calculate the increase from one to the next invoice.
Create a formula {@increase}:

sum({@col2},{table.customerID})-sum({@col1},{table.customerID})

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top