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

Writing formulas selecting fixed denominator

Status
Not open for further replies.

dunken

Technical User
Jul 13, 2003
2
SE

Id like to write a formula ("@NoxDiff") that select NOx from each year after 1995 and divide it with NOx from 1995. My table include among others following values;
Town, Year, NOx, SO2, H+
Stockholm, 1995, 400,
Stockholm, 1996, 360
Stockholm, 1997, 355
Stockholm, 1998, 353
Stockholm, 1999, 255
Stockholm, 2000, 274
Malmo, 1995, 350
Malmo, 1996, 370
Malmo, 1996,

How shall i write it?
The resulting table would include the following indexes;
Town, Year, I(NOx)
Stockholm, 1996, 0.9
Stockholm, 1997, 0.8875
Stockholm, 1998, 0.8825
....
I have CP ver 9.
Please I´ve spent two days testing different formulas - I have small experiense from programming..
 
Use a variable to do this.

In the group header to reset the variable by city:
WhilePrintingRecords;
Numbervar Demon:=0

In the details section to calculate the demoninator:
WhilePrintingRecords;
Numbervar Denom;
If {year}=1995 then Numbervar Denom:={AmountField} else Denom

In the details section to calculate the percentage:
WhilePrintingRecords;
{AmountField}/Numbervar Base

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
OK Thanks - fast service!!!
It doesnt work => Can U se wats wrong

///Im going to put the formula into Cross tabs for each city => do you think I must have this part? If so - Will it be in the same formula?
//In the group header to reset the variable by city:
//WhilePrintingRecords;
//Numbervar Demon:=0

//In the details section to calculate the denominator:
WhilePrintingRecords;
Numbervar Denom;
If {arsdata_.year}=1995 then Numbervar Denom:={arsdata_.NOx} else Denom

//the details section to calculate the percentage:
/// Isnt somethíng missing here? - The declaration of Base?
WhilePrintingRecords;
{arsdata_.NOx}/Numbervar Base
 
I do not recommend using a cross tab for this. Just use a regular report with a group by city. I am unsure how a crosstab will affect this formula.

On the last formula, I don't know where my head was, it should read as follows:

WhilePrintingRecords;
{AmountField}/Numbervar Denom

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
You also want to check that all your variables are called Denom as opposed to Demon as above.

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top