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

Formual based on report section?

Status
Not open for further replies.

makan44

Technical User
May 13, 2005
5
US
Hello,

I was wondering if I can make a formula evaluate differently depending on which report section it is in.

I am using Crystal 9.0 with SQL Server 2000.

I have a formual that gets the average or orders placed per month and it looks like this...

****************************************
numberVar MonthsOverall := ((DateDiff ("d", Minimum({PROC.Ordered_DT}, {@fld_Country_NM}), DataDate)) / 30);

If DistinctCount({PROC.Shipment_NO}, {@fld_Country_NM}) > 0 Then
If MonthsOverall >= 1 Then
DistinctCount({PROC.Shipment_NO}, {@fld_Country_NM}) / MonthsOverall
Else
DistinctCount({PROC.Shipment_NO}, {@fld_Country_NM})
Else
0.00
*****************************************
I actually have 3 versions of this formula 1 for Overall, 1 for Country Group & 1 for Site Group.

I wanted to make it 1 formual instead of 3 seperate formula's.

I wanted to do something like this...

If ReportSection = ReportHeader then
xyz
Else if ReportSection = CountryGroup then
xyz
Else
xyz



anyone know if something like this is possible?




 
Not that I know of, and I don't see that it would buy you much except to confuse things come maintenance time.

The formula is incorrect for the month difference portion:

numberVar MonthsOverall := ((DateDiff ("d", Minimum({PROC.Ordered_DT}, {@fld_Country_NM}), DataDate)) / 30);

Months have more and less than 30 days, try:

numberVar MonthsOverall := DateDiff ("m", Minimum({PROC.Ordered_DT}, {@fld_Country_NM}), DataDate);

-k
 
Hmm, ok thanks. I figured you couldnt do that - but it would be a cool if you could.

I have requirements that state a month will be based on 30 days so I need to do it this way. I appreciate the advice though.

I actually was thinking the opposite as far as maintenance. I am creating templates for standard reports and right now report developers are putting the wrong formula in the wrong section or putting the same one in all 3 sections. They also need to change it to an avg per week formula & dont always change it in all 3 places. Well i shouldnt say they cause I'v edone it myself :)

I feel that having only one formula would decrease the chance for error. See the only difference in the 3 formulas is in the DistinctCount statement. 2 take a group argument & the overall one doesnt.

Thanks Again.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top