We buy goods in both Liters and Gallons, but want to have a field that shows the computed gallonage.
I've been trying this:
CASE
WHEN (PURCHASE_TYPE = 'Liters')
THEN PURCHASE_VOLUME * 3.7854
ELSE
PURCHASE_VOLUME
END
It continues to give me a server error. When I don't use case it works fine.
How should I be doing If / else statemetns for a computed field?
Solved! Go to Solution.
Solved by jpiggee. Go to Solution.
Kjiel,
Using a basic test of 4 fields:Auto number (used to track item in workspace)PURCHASE_TYPE (used as your switch for 'liters')
PURCHASE_VOLUME (used as base count)Adjusted (output for adjusted field)
I was unable to find an issue with you case statment outside of the lack of spaces in some areas.
please try again with the modified case statement and the test above.
CASE WHEN(PURCHASE_TYPE = 'Liters')THEN PURCHASE_VOLUME * 3.7854 ELSEPURCHASE_VOLUME END
Kjiel,
Also please remember if you are using this with a combination with a picklist, pick list are defined by order position such as
0 = pints
1= liters
2 = gallons
The location of the item in question is constant, but the position of the item needs to be located in order to find what you want to compare against.
The location of the item in question can be found by creating a computed field equal to the pick list field in question. Once you have this information then you can run a comparison.
For example:
if liters is equal to 0
Then you case script would be:
CASE WHEN
(PURCHASE_TYPE = '0')THEN PURCHASE_VOLUME * 3.7854 ELSE
PURCHASE_VOLUME END
If liters is equal to 1
Then your case script would be:
CASE WHEN
(PURCHASE_TYPE = '1')THEN PURCHASE_VOLUME * 3.7854 ELSE
PURCHASE_VOLUME END