May 19, 201510 yr I have attached a simplified file with a calculated field that does not work. The calculated field is: Case (LeftWords (DISPOSITION;1 = "DIED") or LeftWords (DISPOSITION;1 = "EUTHANIZED") and IsEmpty(DATE OF DEATH); "DATE OF DEATH NOT ENTERED") I want the warning displayed if the disposition is either "DIED" or "EUTHANIZED" and the DATE OF DEATH field is empty. Thanks in advance. Untitled.fp7.zip
May 19, 201510 yr Don't have to be that complicated. If ( DISPOSITION = "DIED" or DISPOSITION = "EUTHANIZED" and IsEmpty ( DATE OF DEATH ); "DATE OF DEATH NOT ENTERED" ; "" ) What was your reasoning behind the choice of leftwords? Edited May 19, 201510 yr by Kris M
May 19, 201510 yr Don't have to be that complicated. Indeed, but one should still observe operator precedence: Case ( ( disposition = "died" or disposition = "euthanized" ) and IsEmpty ( dateOfDeath ) ; "Date of death not entered")
May 19, 201510 yr Case (LeftWords (DISPOSITION;1 = "DIED") or LeftWords (DISPOSITION;1 = "EUTHANIZED") and IsEmpty(DATE OF DEATH); "DATE OF DEATH NOT ENTERED") Problem #1: LeftWords (DISPOSITION;1 = "DIED") That's bad syntax. It should have been: LeftWords (DISPOSITION;1)= "DIED" The way you have it, it evaluates 1 = "DIED" first. This returns 0, and that's the number of words the LeftWords() function will return. Problem #2: AND is evaluated before OR. The way you have it (after fixing problem #1) will return the warning if the field begins with "DIED", regardless of the date being empty or not. Problem #3: The result type of the calculation should be Text.
May 19, 201510 yr If ( DISPOSITION = "DIED" or DISPOSITION = "EUTHANIZED" and IsEmpty ( DATE OF DEATH ); "DATE OF DEATH NOT ENTERED" ; "" ) Problem #2: - see above. BTW, an empty default result is entirely redundant.
Create an account or sign in to comment