Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

Create simplified data range in Crystal Reports

Hi Experts,

I need to create 2 month / Year range parameters..Where the results are based on
{GlPeriod to GlPeriod } in {GlYear to GlYear}
to
{GlPeriod to GlPeriod} in {GlYear to GlYear}

I was hoping to have 1 Paramter for the first range of GlPeriod / GlYear to GlPeriod / GlYear

and another for GlPeriod2 / GlYear2 to GlPeriod2 / GlYear2

my available fields are {GlPeriod} and {GlYear}

I hope this make sense
0
Mikeyman_01
Asked:
Mikeyman_01
1 Solution
 
LinInDenverCommented:
I think there must be a typo in your post, but I will try to help anyway.

You can use between in Crystal record selection.

Even if your GL periods are stored as text, you should still be able to do this.

Create a RANGE parameter that is a text.  "Range" is in the lower part of the parameter set up.  Instruct your users to enter the range is PPYYYY format (periodyear format). Repeat this for your second parameter range so that you have two parameters.

In your report selection your formula would look something like

//concatenates your two single fields into one to compare against parameter.
(
{table.GLPeriod}&{table.GLYear} in minimum({?Param1}) to maximum({?Param1})
)
OR
(
{table.GLPeriod}&{table.GLYear} in minimum({?Param2}) to maximum({?Param2})
)
0
 
mlmccCommented:
You can use the ranges directly

(
{table.GLPeriod}&{table.GLYear} in {?Param1}  
)
OR
(
{table.GLPeriod}&{table.GLYear} in {?Param2}
)

mlmcc
0
 
Mikeyman_01Author Commented:
i Have created a Record Selection formula  ({@StartRange1} in {?StartRange1} to {?EndRange1})

@StartRange1 = ToText({ArTrnDetail.GlPeriod},0,"") +  ToText({ArTrnDetail.GlYear},0,"")

My @Sales formula = if {@StartRange1} in {?StartRange1} to {?EndRange1} then  {ArTrnDetail.NetSalesValue}
else 0


If i enter 32013 at {?StartRange1}and 52013 at {?EndRange1} i get all Sales Data from the beginning of time... but when i enter 32013 at both of these prompts i get only 32013 Sales Data.. How can i build this so i get only the Sales information between these
0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 
James0628Commented:
I wouldn't expect 32013 to 52013 to give you "all Sales Data from the beginning of time", but it would include period 4 in any year, and period 5 in any year up to 2013 (and period 3 in any year after 2013).  You need to have the year first.

  And assuming that the period numbers go above 9, you also need to include a leading 0 on the period numbers below 10.  Ignoring the year for the moment, a range like period 5 to 11 won't work, because "5" is greater than "11".  It needs to be "05", or " 5" (with a leading space).

 Putting the year first and assuming a 2 digit period with a leading 0, if necessary, you could change @StartRange1 to:

ToText({ArTrnDetail.GlYear},0,"") + ToText({ArTrnDetail.GlPeriod},"00")


 And, of course, you need to rearrange your parameter values to be year then period.  Assuming that they will always be pyyyy (for the periods below 10) or ppyyyy, you could use something like:

Mid (Right ("0" + {?StartRange1}, 6), 3, 4) + Left (Right ("0" + {?StartRange1}, 6), 2)

 James
0
 
Mikeyman_01Author Commented:
Hi James

How do I work this piece of the formula into my report??

Mid (Right ("0" + {?StartRange1}, 6), 3, 4) + Left (Right ("0" + {?StartRange1}, 6), 2) not sure where to put this
0
 
James0628Commented:
Sorry.  I was kind of in a hurry there.  Just replace the parameter in your formula with that code.

if {@StartRange1} in {?StartRange1} to {?EndRange1} then
  {ArTrnDetail.NetSalesValue}
else
  0

  would become

if {@StartRange1} in
 Mid (Right ("0" + {?StartRange1}, 6), 3, 4) + Left (Right ("0" + {?StartRange1}, 6), 2) to
 Mid (Right ("0" + {?EndRange1}, 6), 3, 4) + Left (Right ("0" + {?EndRange1}, 6), 2) then
  {ArTrnDetail.NetSalesValue}
else
  0


 FWIW, if you don't already know, what that code does is add a "0" to the front of the parameter value, so, for example, "52013" would become "052013" and "112013" would become "0112013", and then it takes the rightmost 6 characters, which would give you "052013" and "112013".  IOW, it adds a leading "0" if the period is just one digit, so the parameter will look like ppyyyy.  Then it uses Mid to extract the year (4 characters, starting at the 3rd position) and the two digit period (the leftmost 2 characters) and concatenates them together.  So, "52013" becomes "201305" and "112013" becomes "201311".

 If you're going to be using those parameters in other formulas and need the values "converted" there too, you could create a formula for each parameter that "converts" the value.  For example:

// start_range_ppyyyy
Mid (Right ("0" + {?StartRange1}, 6), 3, 4) + Left (Right ("0" + {?StartRange1}, 6), 2)

// end_range_ppyyyy
Mid (Right ("0" + {?EndRange1}, 6), 3, 4) + Left (Right ("0" + {?EndRange1}, 6), 2)


 Then the earlier formula would be:

if {@StartRange1} in {@start_range_ppyyyy} to {@end_range_ppyyyy} then
  {ArTrnDetail.NetSalesValue}
else
  0


 And, as I mentioned before, the way that I'm rearranging the parameter values is based on the assumption that they will _always_ look like pyyyy (for the periods below 10) or ppyyyy (for periods 10 and up).  If the parameter values could be different (maybe the user types them in and could just make a mistake), then you might want to add some error checking.  In that case, it would probably be easier to use a formula to "convert" each parameter, and include the error checks in those formulas.  You'd have to decide how you wanted the report to handle an invalid value (eg. if the user mis-typed the year and entered 5203 instead of 52013).

 James
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now