|
Run-time Variable Sorting - Let the user choose
It often happens that a particular
report format is attractive to more than one audience. For
instance, a monthly sales performance report is provided to the
National Sales Manager who likes to see it sequenced by Sales
Territory. The VP of Marketing is equally interested in the sales
figures, but likes to see the report presented by Customer
Group.
You can build this kind of
flexibility in a single report by using calculations and parameters.
Here's how to approach the task:
First identify which Subset (or
other data source) you need to access the data you require. Now,
identify the particular fields that you need to control the output
sequence for your two audiences.
For this example, let's assume
that the first is "Sales Territory" - a 10 Character
field and the other is "Customer Group" - a 6 Character
field.
Using Jacana, create a new report
and base it on a template rather than using a wizard - you can use
the wizard later to design the page layout.
Firstly, create a calculation
(CALC00001) to
base a parameter upon (you only need this field to choose the
report output sequence so a character field of length 1 is
sufficient). Now, via the "Parameters" tab of the report
specifications dialog, add it to the report Parameters. Use the
"Run-time Interface" button
from the toolbar to add text
to the parameter that will explain to the user what run-time
choices are available and how to make their choice. For
example:
- TEXT: Choose output
sequence:
- TEXT: By Territory - Enter "1"
- TEXT: By Customer Group - Enter
"2"
- PARM: _______________? Show me
Now create another calculation to
hold the value which will be used to sort the output. From the
"Properties" dialog, use the "General" tab to
set the length of this calculation. Choose a length sufficient to
contain the longer of your 2 possible sort control values. In this
example, you need a 10 Character field to hold the Territory
Code. Show me
Add a condition to this
calculation to test the parameter. Assign the Territory Code into
the calculation when the parameter is equal to "1" and
the Customer Group code when it is not.
Tip: Given that you
expect the parameter to contain either 1 or 2, you should only
test for "1" and let the "2" case be handled
by the "else" condition of the calculation. By doing
this, you make sure that your report adopts reasonable
"default" behaviour if the run-time user makes an error.
Thus, test for "1" and assign the Territory Code to the
calculation. Place no further condition on the calculation and set
the "else" case to assign the "Customer Group
Code" to the calculation (i.e. when the parameter is not
"1"). Now, if the run-time user accidentally types
"3", the report will be produced in its
"default" output sequence - "Customer Group
Code".
Now run the report wizard and
design your report page layout. In the Sorting dialog, choose
CALC000002 as your sort control (remember, CALC00002 will contain
Territory Code if the run-time user types "1" or
"Customer Group Code" if the user types anything else.)
In the layout dialog, choose
Territory Code to be printed first - do not choose Customer Group
code at all. Complete the wizard until you are in the Jacana
layout window with the page layout in view.
Now, copy your detail line (and/or
your CALC00002 sort lines) and paste it after the existing line.
Alter this second line by removing the Territory code and
inserting the Customer Group code. Now, with the cursor on the
"Territory line" use a right-mouse-click and choose the
"Line properties" option. In the Line properties dialog Show me,
access the "Conditioning" tab and set this line to print
only when the parameter holds the value "1".
Repeat this process for the
"Customer Group" line setting the condition to only
print when the parameter does NOT hold the value "1"
(again, ensuring valid "default" behaviour even if the
user accidentally types "3"). Show me
If you have more than 2
alternative sort sequences, simply allow for further possible
values of the parameter when you specify the conditioning for
CALC00002 and for the print lines. Remember to choose a
"default" value and only test for the other
possibilities - assume your "default" value in your ELSE
case.
Now copy the column headings so
that you have one set with the first column headed
"Territory" and one with the first column headed
"Customer Group". Condition these heading lines to match
the detail lines.
Finally, for completeness, copy
say, heading line 2 and add text to these lines to explain the
report sequence. Again, repeat the conditioning used on the detail
lines to ensure consistency in the printed output. For example,
one of these lines will be conditioned to print only when the
parameter is "1" and this line will contain the text,
"Sales By Territory".
Be sure to check that the
conditioning in the calculation is consistent with the
conditioning that you specify against the various print lines.
You now have one report which
serves both purposes. Each user of this report can set up their
own Valet Run-set with their personal preference built-in to the
parameter.
Do you have any specific questions
you'd like answered? Let us know momentum@jacana.com
|