Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula for getting records previous month Post Reply Post New Topic
Author Message
Elisha83
Groupie
Groupie


Joined: 19 Feb 2008
Location: Malaysia
Online Status: Offline
Posts: 62
Quote Elisha83 Replybullet Topic: Formula for getting records previous month
     Posted: 18 Aug 2008 at 8:45pm
Hi there~

I need some help on writing a formula to get a stock quantity on hand balance from previous month based on  the cut off month that I entered.

Example:
If i enter Cut Off Month : July, then it will show the stock quantity balance for June.


Can anyone guide me on this formula?


Thanks in advance.


Elisha Smile
3Lish@
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 19 Aug 2008 at 12:38am
Hi,
 
 
you must have already created a parameter to enter months remember to restrict the user to enter the Months in fixed format or else the formula 2 will  not work what you can do is create a DropDown List of Month Parameter which will be non editable.....
 
 
Then create a formula to get Month Name
 
Frm1
Monthname(month({Table.Datefield}))
 
Then create another formula to convert the entered Month in paramter to number.
 
Frm2 this checks what month name you have entered in parameter
 
Select {?My Parameter}
   Case "January","Jan" :
      01
   Case "Feburary","Feb":
      02
 Case "March","Mar" :
      03
   Case "April","Apr":
      04
 Case "May":
      05
   Case "June","Jun":
      06
 Case "July" ,"Jul":
      07
   Case "August","Aug":
      08
 Case "September","Sep" :
      09
   Case "October", "Oct":
      10
 Case "November" ,"Nov":
      11
   Case "December","Dec":
      12

 
 
Then in the record selection formula
 
Compare  the following
 
month({Table.Datefield}) = Frm2-1
 
 
So if you enter June in parameter it will give records for May and so on.....
 
Cheers
Rahul
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