6 Replies Latest reply on Apr 29, 2011 9:07 AM by philmodjunk

    Case script help



      Case script help


      Case ( Book Name = "Canceled"; "0" ; Division = "INTL_Europe" or Division = "INTL_Japan" or Division = "INTL.NE" or Division = "INTL.CE"; PageCount_Body * 243; Division  ≠  "INTL_Europe" or Division  ≠  "INTL_Japan" or Division  ≠  "INTL.NE" or Division  ≠  "INTL.CE"; Page Count * 395)

      Need help with this script. It isn't working. Book names that include the work canceled are not bringing back a 0. Any ideas?

      Hopefully you won't need a complete explanation of what this script is for.


        • 1. Re: Case script help

          Picky detail: This is a calculation, not a script. Wink

          Case ( Book Name = "Canceled"; "0" ; 
                    Division = "INTL_Europe" or Division = "INTL_Japan" or Division = "INTL.NE" or Division = "INTL.CE";
                    PageCount_Body * 243; Division  ≠  "INTL_Europe" or Division  ≠  "INTL_Japan" or Division  ≠  "INTL.NE" or Division  ≠  "INTL.CE";
                           Page Count * 395

          It's easier to work with Case Functions if you re-arrange them as shown above.

          Syntax looks correct if the only text is "canceled" and no other characters are part of the text in this field. (And comparision is NOT case sensitive, so that's not an issue.)

          You describe this as Book Name INCLUDES "canceled". If there is any other text included with the word "canceled" in this field, you would need to modify the first parameter with something like:

          PatternCount ( Book Name ; "Canceled" )

          And I'd be careful of a book title, that for some reason includes "canceled" in its title here. It might be better to add a separate status field to check for "canceled" instead of putting it in the book name field.

          If you are putting the single word "canceled" in this field and it's not working for you, check the field type of Book Name to make sure that it is of type text and not of type number and check to make sure that no invisible characters such as a space or return is being entered along with the visible text.

          • 2. Re: Case script help

            You're right, script was wrong choice of word.

            Canceled is part of the book name. We do have a status field that indicates canceld or active, but it is hard to explain why we need it in the book name too. Long story short, we need to keep canceled books active for some time before we move them to inactive status. Until then they need to indicate canceled.

            I'm confused by the patterncount function. I don't need a count of anything. Basically I just don't want it to calculate anything if the word canceled is in the book name. How would patterncount work for this?

            • 3. Re: Case script help

              Since pattern count will return the number of times that "canceled" is included in the field, it will return a number of 1 or larger if you have that word entered in the field. Nonzero numbers are evaluated as true. 0 or empty (null) values are evaluated as false.

              I'd still remove "canceled" from the book name field and use a more sophisticated handling of the status field values if I were you. It may be very unlikely, but your calculation will fail if a book needs to include "canceled" as part of its title.

              There are also text functions you can use to extract and compare the first or last word of your text field to see if it is "canceled" if you always put "canceled" in the same place in the field. That would make such a problem even more unlikely, but still leaves a tiny chance that an unusual book name could cause a problem here.

              • 4. Re: Case script help

                Just a thought...

                {Division  ≠  "INTL_Europe" or Division  ≠  "INTL_Japan" } will always evaluate as TRUE, no value will equal both exact texts...so it's useless having it there at all, let it be the default end value instead and simplify the expression.

                From the above discussion, including a "BookStatus" field, it looks like this would be worth a try:

                Case ( BookStatus = "Canceled"; "0" ; 
                          Division = "INTL_Europe" or Division = "INTL_Japan" or Division = "INTL.NE" or Division = "INTL.CE";PageCount_Body * 243;
                          Page Count * 395

                Just thinkin' out loud....

                • 5. Re: Case script help


                  You are right. My original calculation (before the canceled issue came up) says

                  Case (Division = "INTL_Europe" or Division = "INTL_Japan" or Division = "INTL.NE" or Division = "INTL.CE"; PageCount_Body * 243; Page Count * 395)

                  And based on Phil's and your comment, I'm going to go back and add a field as part of the book name that says cancelled. Hopefully that solves the problem.

                  • 6. Re: Case script help

                    Good Catch! I'd stayed focused on the initial term and hadn't looked closely enough at that last pair of parameters.