Focal Point
[CLOSED] INVALID Expression on COMPUTE

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5987022886

November 03, 2017, 03:54 PM
BSBAL18
[CLOSED] INVALID Expression on COMPUTE
Why is this erroring with invalid expression when i insert a new compute field in the MAS file?

SUM.TOTAL_MISMATCHES / IF DIV_SHORT_NAME = 'CENTRAL'
THEN 308 ELSE IF DIV_SHORT_NAME = 'WEST' THEN 198
ELSE 110

"(FOC266) IF .. THEN .. ELSE .. SYNTAX ERROR"

This message has been edited. Last edited by: FP Mod Chuck,


AS Version: 8201
Gen: 10202016
Windows, All Outputs
November 03, 2017, 04:10 PM
MartinY
quote:
SUM.TOTAL_MISMATCHES / IF DIV_SHORT_NAME = 'CENTRAL' THEN 308 ELSE IF DIV_SHORT_NAME = 'WEST' THEN 198 ELSE 110


A "perfect" COMPUTE syntax may look as the following :

COMPUTE fieldname /format = IF DIV_SHORT_NAME EQ 'CENTRAL' THEN 308 ELSE IF DIV_SHORT_NAME EQ 'WEST' THEN 198 ELSE 110;


It looks like you have a weird syntax : SUM.TOTAL_MISMATCH / IF ... = ...
Difficult to know where is the compute field's name and what is the compute function itself.

Equal sign (=) may be recognized in WF, but I normally not use it in a IF THEN ELSE to avoid confusion between the assignation (=) and the equal test (EQ).


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
November 03, 2017, 04:56 PM
Doug
The missing / operative keyword is "COMPUTE" and COMPUTEs require a semi-colon termination not to mention a dash prefix for multiple lines.