|
|||||||||
|
Crystal Reports Tools: Improve Performance While Saving Time and Money |
|
Crystal Reports: Upto and UpfromUseful "upfrom" and "upto" keywords The Select Case control structure is a useful programming technique if your conditions all rely on the same variable. It is more efficient and processes a lot faster than a nested ‘if …then …else …’ statement.
You can specify a single value(1), multiple values (3,6,7) or a range (2 to 5). But what if our ranges are open ended? You can also use the "upto" and "upfrom" keywords to handle these situations. Expand the formula above to handle this with
This article is copyrighted by Crystalkeen, Mindconnection, and Chelsea Technologies Ltd. It may be freely copied and distributed as long as the original copyright is displayed and no modifications are made to this material. Extracts are permitted. The names Crystal Reports and Seagate Info are trademarks owned by Business Objects. |
More thoughts on Select CaseWhile nested if …then …else …’ statements work very well, they become confusing for most people on that third nesting. When you must nest more than that to achieve a particular goal, it's certainly doable. Many good engineers have nested quite deeply in Excel, for example, with the results they intended. Ditto for Crystal Reports. But try going back after a few months, and see if you can follow the logic and the nesting trail. This is where nesting starts to seem like an exercise in sadism if it's someone else's code or masochism if it's your own. While you may be perfectly happy whipping out multiple nestings to get something done, you may later rue the day you did that. The alternative is to take the time to learn Select Case and then use it appropriately. Be careful to use the correct syntax in your Select Case statement. This is what defines the field against which the Case will compare the criteria. Follow each criterion with a colon, as in the examples above, e.g., Case 1: and after the colon type in the desired results in quotes. For Case 1, that would be "low" as in the example above. You actually have a lot of leeway with what the results can be. The results can even be a formula. Experiment with this and see what you can do. Now, this brings us back to the original issue of multiple nestings. Why do you need such convoluted logic to get a result? Perhaps the result is so far removed from the data that:
Maybe the real solution here is to question the desired result. Why does the report recipient need to know that? Sure, it's your job to provide people with the information they need. But perhaps what they request and what they need are not the same thing. To find out, carefully interview the requestor. If there's not a requestor, find out why this result was put on the To Do list and see if that is a real business intelligence need. When you research by asking people, don't ask, "Why do you need to know this?" because you'll just get a defensive answer. Instead, explain that to get the result requires a very convoluted manipulation of the data and that makes you question how useful the result is. Ask what the business goal is and explain that you're trying to find an accurate and fairly direct way of supporting it. You may find your job is greatly simplified. But if not, then turn to Select Case to avoid mind-numbing nesting structures. |