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!

Formula Help OR Why isn’t this working 1

Status
Not open for further replies.

Bennie47250

Programmer
Nov 8, 2001
515
US
Using Crystal 7.0

This seems like a simple formula but it is not working unless I have included in some fields that seem meaningless. This one has me baffled. This is long so please stay with me.

All of the formulas are in the group footer.

The formula that does not seem to be working correctly is named “$ Performance to Forecast" and is as follows:

if {@2000 YTD Unit Global Declarator} = 0
then 0
else if {@TotalDistYTD$} = 0
then 0
else if {@TotalYTDDistForecast$} = 0
then 0
else {@TotalDistYTD$}%{@TotalYTDDistForecast$}

The {@2000 YTD Unit Global Declarator} formula is:
shared numbervar y2000units;
y2000units:={@Total Curr YTD Units}

The {@TotalDistYTD$} formula is:
{#Dist Sales $ YTD}+{#HD Sales $ YTD}

The {@TotalYTDDistForecast$} formula is:
{@YTDForecastHD$}+{@YTD Forecast Distributor $}

The value for {@2000 YTD Unit Global Declarator} is 253
The value for {@TotalDistYTD$} is 1135432
The value for {@TotalYTDDistForecast$} is 1575000

I’m thinking that since {@2000 YTD Unit Global Declarator}, {@TotalDistYTD$} and {@TotalYTDDistForecast$} all are not equal to 0, I should be able to simply use this as the formula {@TotalDistYTD$}%{@TotalYTDDistForecast$}.

However when I do this, the field is blank.

If I write the formula this way

if {@2000 YTD Unit Global Declarator} = 0
then 0
else {@TotalDistYTD$}%{@TotalYTDDistForecast$} I get the correct answer. (72.1%)

It seems to me that for some reason the formula (thinks it) needs the if {@2000 YTD Unit Global Declarator} = 0 then 0 condition.

Can anyone show me the error of my ways?

Thanks
 
Try tacking a whileprintingrecords; to the front of your "$ Performance to Forecast" formula. Crystal may be trying to evaluate this formula before the formula using the shared variable ({@2000 YTD Unit Global Declarator}) formula.

Making it:
whileprintingrecords;
if {@2000 YTD Unit Global Declarator} = 0
then 0
else if {@TotalDistYTD$} = 0
then 0
else if {@TotalYTDDistForecast$} = 0
then 0
else {@TotalDistYTD$}%{@TotalYTDDistForecast$}


Mike
 
For simplicity I would write the formula as

if {@2000 YTD Unit Global Declarator} = 0 or
{@TotalDistYTD$} = 0 or
{@TotalYTDDistForecast$} = 0
then 0
else {@TotalDistYTD$}%{@TotalYTDDistForecast$}

If this still fails, and none of your formulas evaluate to null.. then you have a different problem.

Lisa
 
mbarron, inserting the whileprintingrecords did the trick.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top