Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 1st, 2012  |  syntax: None  |  size: 1.09 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to reference a previous group for year-on-year calculations in a Crystal Report?
  2. 2010  
  3.    January    £20,000
  4.    February   £30,000
  5.    March      £15,000
  6.    etc.
  7.  
  8. 2011
  9.     January   £16,000
  10.     February  £14,000
  11.        
  12. 2010
  13.     January
  14.         Company 1    £5,000
  15.         Company 2    £7,000
  16.         Company 3    £8,000
  17.        
  18. Global StringVar JanGlobal;
  19. Local NumberVar NumberToCompare := 0;
  20. If Year(Sales) = 2010 Then
  21.     JanGlobal := '||' + {CompanyName} + '|' + ToText({SalesFigure}); //append current value to Jan's formula
  22. Else
  23. (
  24.     If UBound(SalesSearch) > 0
  25.     (
  26.         Local NumberVar Searching := 1;
  27.         For Searching = 1 to UBound(SalesSearch)
  28.             If SalesSearch[Searching] StartsWith ({CompanyName} + '|') Then
  29.             (
  30.                 Local StringVar Array Matched := Split(SalesSearch[Searching], '|')
  31.                 NumberToCompare := ToNumber(Matched[2]);
  32.             )          
  33.         Next
  34.     )
  35.     //do whatever you want with the 2011 sales figure and the value of NumberToCompare
  36.     //(which should be either zero or Jan 2010's sales figure for the company) here
  37. )