Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: rolling forecast report syntax Post Reply Post New Topic
Author Message
gemcka
Newbie
Newbie


Joined: 02 Aug 2011
Online Status: Offline
Posts: 16
Quote gemcka Replybullet Topic: rolling forecast report syntax
     Posted: 31 Aug 2011 at 3:31am
Hi,
 
i am having troupble with the syntax for the following formula..
 
If Month(currentdate) >11
then MONTH({CASE_VOLUME\\.MSDATE}) = Month(currentdate)-11 and Year({CASE_VOLUME\\.MSDATE})= year(currentdate)+1
 Then {PART_PRICE_COST_SET\\.UNIT_COST_CS1}*{CASE_VOLUME\\.FORECAST_CASE_QTY}*{RECIPE_BREAKDOWN_4B\\.QTY}
else
IF MONTH({CASE_VOLUME\\.MSDATE}) =  Month(currentdate)+1
THEN {PART_PRICE_COST_SET\\.UNIT_COST_CS1}*{CASE_VOLUME\\.FORECAST_CASE_QTY}*{RECIPE_BREAKDOWN_4B\\.QTY}
ELSE 0
 
Is there an obvious error I am missing??
how do you get the 2nd 'then' included?
 
thanks


Edited by gemcka - 31 Aug 2011 at 4:13am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Aug 2011 at 3:52am
what exactly are you trying to achieve here?
IP IP Logged
gemcka
Newbie
Newbie


Joined: 02 Aug 2011
Online Status: Offline
Posts: 16
Quote gemcka Replybullet Posted: 31 Aug 2011 at 4:13am
This is from a rolling forecast repot that looks at our forecast figures for the months ahead and gives costs of required components for the recipes.
the previous report works OK
IF MONTH({CASE_VOLUME\\.MSDATE}) =  1
THEN {PART_PRICE_COST_SET\\.UNIT_COST_CS1}*{CASE_VOLUME\\.FORECAST_CASE_QTY}*{RECIPE_BREAKDOWN_4B\\.QTY}
ELSE 0
 
 as long as I restrict the selection to the current year or next year using select expert
 
but now a rolling 12 months is required and when the month goes into the new year I get forecast results from JAN 2011  AND  Jan 2012!
 
The error I get is " the remaining test does not appear to be part of the formula"   and the text after "year(currentdate)+1 " is highlighted.
 
Sorry if this is not clear - my brain is a bit scrambled at the mo!!
 
Thanks
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Aug 2011 at 4:42am
Crystal can't really create rows of data so that is why I am confused on your process here.
Your previous worked because it is  simply doing a calculation where if the row has a date of Jan then use unitcost*forecast case qty*qty otherwise insert a 0.
Your new fomrula looks like you are trying to make rows of data and define joins from tables in the formula.
if you alter your existing formula to not use if then and just run the calculations
//
PART_PRICE_COST_SET\\.UNIT_COST_CS1}*{CASE_VOLUME\\.FORECAST_CASE_QTY}*{RECIPE_BREAKDOWN_4B\\.QTY}
//
you can group on {CASE_VOLUME\\.MSDATE} set to the month and sum the value for the group


Edited by DBlank - 31 Aug 2011 at 4:43am
IP IP Logged
gemcka
Newbie
Newbie


Joined: 02 Aug 2011
Online Status: Offline
Posts: 16
Quote gemcka Replybullet Posted: 31 Aug 2011 at 11:12pm
Thanks DBlank,
I have had a play and I think I can get the results I want but I am struggling with the format/layout...
the user would like the report to display
component part          this month       next month     month after   etc...
component                   value                value             value
 
but I can't arrange this using the groups.
 
another idea was somthing like 
IF Month({CASE_VOLUME\\.MSDATE})= month (dateadd('m',+1,((currentdate))))
THEN {PART_PRICE_COST_SET\\.UNIT_COST_CS1}*{CASE_VOLUME\\.FORECAST_CASE_QTY}*{RECIPE_BREAKDOWN_4B\\.QTY}
ELSE 0
 
but - does the date add take into account the year?  so when it date add 1 month onto december 2011 it then looks at jan 2012?
 
i am about to try it in another report so will post the results here a bit later!
Cheers
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Sep 2011 at 3:40am
dateadd does roll into the next year (or previous year of you are subtracting).
IP IP Logged
gemcka
Newbie
Newbie


Joined: 02 Aug 2011
Online Status: Offline
Posts: 16
Quote gemcka Replybullet Posted: 01 Sep 2011 at 4:04am
Perfect!Big%20smile
report doing exactly what I wanted!!
Many Thanks.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum