Hi, I am trying to write a script that will display a specific number if an “Industry” (the fundamental field) is “PharmaceuticalsMajor”. Unfortunetly, the script i am using always provides a true result. Below is the script:
Industry1=DATAFIELD(Month(PERIODAMOUNT=1), FEED=FD, FIELD=Industry);
Industry2=If(Industry1=="PharmaceuticalsMajor, 1, 0);
Industry2;
The above scripts results in “1” for all stocks. For example, TSLA which is under the Industry MotorVehicles displays a “1” in the above script. The pharmaceeutical stocks also shows true as expected.
Thank you!
oops. I had a typo and was missing an ". Fixed below but still the same result as noted in the original post
Industry1=DATAFIELD(Month(PERIODAMOUNT=1), FEED=FD, FIELD=Industry);
Industry2=If(Industry1==”PharmaceuticalsMajor", 1, 0);
Industry2;
Hi Michael,
When using text values in fundamental data you need to use the MATCHFUNFIELD() function instead of DATAFIELD:
https://www.optuma.com/kb/optuma/scripting/formulas-and-scripting-functions/matchfunfield
So for your example use the following:
Industry1=MATCHFUNFIELD(FEED=FD, FIELD=Industry, FIELDVALUE=PharmaceuticalsMajor);
Industry2=If(Industry1, 1, 0);
Industry2
