Web Intelligence
         &
Crystal Reports
  ----------------
Processing and Context

        Dan Donarski
 Kolb+Co. Technology Advisers
Crystal Reporting Model
Suppose we want to create the following report


  Need to generate a running total for monthly sales that:
  ◦ Are greater than 25% of regions total monthly sales

  Need to also display :
  ◦ Pct Sum of all customer sales > 25% of groups totals




                           BO
Crystal Reporting Model
Report Layout –
  - Grouped by Region / Date / Customer
  - Summary of customer sales
         - By region

-   Formula to display value
    -  if sales > 25% of monthly total



    -   Running total of @Analysis



                           BO
Crystal Reporting Model
…but my RT Expert won’t show fields I need
  - @Analysis




                    BO
Crystal Reporting Model




      BO
             Because a “PrintTime” formula is “processed”
               after Running Totals….
Crystal Reporting Model
Create a formula as “PrintState”
)

    //@Pct of Sales (GF3 – Customer)
    //Set formula to be evaluated at PrintState pass
    WhilePrintingRecords ;
    //Perform calculation
    Sum({Orders.Order Amount}, {Customer.Customer Name})  
    % 
    Sum({Orders.Order Amount}, {Orders.Order Date}, "monthly")



    //@Analysis (GF3 – Customer)
    //Set formula to be evaluated at PrintState pass
    WhilePrintingRecords ;
    //Check to see if criteria met and if so perform calc
    if {@Pct of Sales} > 25 then 
       Sum({Orders.Order Amount}, {Customer.Customer})Name})
Crystal Reporting Model
//@Reset (Hidden in GH2 – Monthly)
//Set formula to be evaluated at PrintState pass
WhilePrintingRecords ;
//Reset the variable we'll use to hold our subtotal
Global CurrencyVar vTotal := 0 ;


//@Accumulate (Hidden in GF3 – Customer)
//Set formula to be evaluated at PrintState pass
WhilePrintingRecords ;
//Declare that we want to make reference to a variable
Global CurrencyVar vTotal ;
//Add to the existing value of the variable
vTotal := vTotal + {@Analysis}

//@Display (GF2 – Monthly)
//Set formula to be evaluated at PrintState pass
WhilePrintingRecords ;
//Display the current value
Global CurrencyVar vTotal ;



                            BO
Crystal Reporting Model

    …Final calculation now able to be performed



//@MonthPct (GF2 – Monthly)
//Declare that we want to make reference to a variable
WhilePrintingRecords ;
//Perform calculation
if {@Display} = 0 then 0 else
    {@Display} % Sum ({Orders.Order Amount}, {Orders.Order Date}, "monthly")




                                   BO
Web Intelligence Context
Aggregation
◦ Calculation of measures
     Three components
         Calculation Function
            Ex: Sum, Avg, Min, Max
         Input Context
            What goes into calculation
            Ex: Dimensions in block
         Output Context
            Where the aggregation is
            output
            Ex: Block Footer, Section,
            Body
                       BO
Web Intelligence Context
Default Aggregation

Calculation(Input Considerations)




        (Output location)



                    BO
Web Intelligence Context




   =Min([Sales revenue] ForAll ([Quarter] ; [Year])) In ([Year])
           BO

                        Input                         Output
Web Intelligence Context




   =Min([Sales revenue] ForEach ([Quarter] ; [Year])) In ([Year])
      BO

                       Input                         Output
Web Intelligence Context




   =Min([Sales revenue]) In ([Year])
                                                                 Output
   =Min([Sales revenue]) In ([Quarter])

   =Sum([Sales revenue]) In ([Year]) Where ([Year] = "2001")
   =Sum([Sales revenue]) In ([Year]) Where ([Year] = "2002")
   =Sum([Sales revenue]) In ([Year]) Where ([Year] = "2003")

   =Sum([Sales revenue]) In ([Year]) Where ([Year] InList("2001" ; "2002" ; "2003") )
Web Intelligence Context




           • Max Sales Revenue By Year
              =Max([Sales revenue] In ([State] ; [Year]))


           • Year of Max Sales Revenue
               =Max(If([Sales revenue] = Max([Sales revenue] 
                     ForEach ([Year])) In ([State]) ; ([Year]) ; 0) 
                     In ([State] ; [Year]))
Web Intelligence & Crystal Reports




          Dan Donarski
      ddonarski@kolbco.com

Reporting Tips

  • 1.
    Web Intelligence & Crystal Reports ---------------- Processing and Context Dan Donarski Kolb+Co. Technology Advisers
  • 2.
    Crystal Reporting Model Supposewe want to create the following report Need to generate a running total for monthly sales that: ◦ Are greater than 25% of regions total monthly sales Need to also display : ◦ Pct Sum of all customer sales > 25% of groups totals BO
  • 3.
    Crystal Reporting Model ReportLayout – - Grouped by Region / Date / Customer - Summary of customer sales - By region - Formula to display value - if sales > 25% of monthly total - Running total of @Analysis BO
  • 4.
    Crystal Reporting Model …butmy RT Expert won’t show fields I need - @Analysis BO
  • 5.
    Crystal Reporting Model BO Because a “PrintTime” formula is “processed” after Running Totals….
  • 6.
    Crystal Reporting Model Createa formula as “PrintState” ) //@Pct of Sales (GF3 – Customer) //Set formula to be evaluated at PrintState pass WhilePrintingRecords ; //Perform calculation Sum({Orders.Order Amount}, {Customer.Customer Name})   %  Sum({Orders.Order Amount}, {Orders.Order Date}, "monthly") //@Analysis (GF3 – Customer) //Set formula to be evaluated at PrintState pass WhilePrintingRecords ; //Check to see if criteria met and if so perform calc if {@Pct of Sales} > 25 then  Sum({Orders.Order Amount}, {Customer.Customer})Name})
  • 7.
    Crystal Reporting Model //@Reset (Hidden in GH2 –Monthly) //Set formula to be evaluated at PrintState pass WhilePrintingRecords ; //Reset the variable we'll use to hold our subtotal Global CurrencyVar vTotal := 0 ; //@Accumulate (Hidden in GF3 – Customer) //Set formula to be evaluated at PrintState pass WhilePrintingRecords ; //Declare that we want to make reference to a variable Global CurrencyVar vTotal ; //Add to the existing value of the variable vTotal := vTotal + {@Analysis} //@Display (GF2 – Monthly) //Set formula to be evaluated at PrintState pass WhilePrintingRecords ; //Display the current value Global CurrencyVar vTotal ; BO
  • 8.
    Crystal Reporting Model …Final calculation now able to be performed //@MonthPct (GF2 – Monthly) //Declare that we want to make reference to a variable WhilePrintingRecords ; //Perform calculation if {@Display} = 0 then 0 else {@Display} % Sum ({Orders.Order Amount}, {Orders.Order Date}, "monthly") BO
  • 9.
    Web Intelligence Context Aggregation ◦Calculation of measures Three components Calculation Function Ex: Sum, Avg, Min, Max Input Context What goes into calculation Ex: Dimensions in block Output Context Where the aggregation is output Ex: Block Footer, Section, Body BO
  • 10.
    Web Intelligence Context DefaultAggregation Calculation(Input Considerations) (Output location) BO
  • 11.
    Web Intelligence Context =Min([Sales revenue] ForAll ([Quarter] ; [Year])) In ([Year]) BO Input Output
  • 12.
    Web Intelligence Context =Min([Sales revenue] ForEach ([Quarter] ; [Year])) In ([Year]) BO Input Output
  • 13.
    Web Intelligence Context =Min([Sales revenue]) In ([Year]) Output =Min([Sales revenue]) In ([Quarter]) =Sum([Sales revenue]) In ([Year]) Where ([Year] = "2001") =Sum([Sales revenue]) In ([Year]) Where ([Year] = "2002") =Sum([Sales revenue]) In ([Year]) Where ([Year] = "2003") =Sum([Sales revenue]) In ([Year]) Where ([Year] InList("2001" ; "2002" ; "2003") )
  • 14.
    Web Intelligence Context • Max Sales Revenue By Year =Max([Sales revenue] In ([State] ; [Year])) • Year of Max Sales Revenue =Max(If([Sales revenue] = Max([Sales revenue]  ForEach ([Year])) In ([State]) ; ([Year]) ; 0)  In ([State] ; [Year]))
  • 15.
    Web Intelligence &Crystal Reports Dan Donarski ddonarski@kolbco.com