Skip to content

NonZero Function

By Optuma Team · Updated 2024-06-18

The NonZero function can be used to find when values are not equal to zero. This is particularly useful when looking for changes in Fundamental data, or boolean conditions where true results have a value of one and false a value of zero.

In this example the Short Interest data - which requires access to our Fundamental database - is plotted below the price chart of Microsoft. Because the Short Interest data is reported every two weeks the value doesn’t change every day, so the usualCHANGE() function can’t be used because it will return 0% (except on the day of the change). Instead, the NonZero() function can be used to find the difference from the previous value.

NonZero function

Here’s now to calculate Microsoft’s 28.9% increase in Short Interest from the previous reporting period:

//Get the Short Interest values;
D1=DATAFIELD(FEED=FD, FIELD=ShortInterest);
//Find daily change;
X1 = D1 - D1[1];
Y1 = IF(X1==0, 0, D1);
//Get previous value of Y1 when Datafield value D1 changed (X1 wasn't 0);
P1 = NONZERO(Y1)[1];
//Calculate % change between current & previous values;
DIFFPCT(D1,P1)/100

When displayed in a watchlist Microsoft’s 28.9% change was the largest increase of the 30 stocks in the Dow Jones Industrial index:

NonZero function

When looking for short interest changes from two reporting cycles ago, Travelers has fallen the most (-13.2%):

NonZero function

Save and open the workbook attached for the above example (requires US Equities and Fundamental Data).

WorkbookRequirementsDownload
NonZero.owbTrader Services, US Equities & Fundamentals

Choose which categories of cookies you allow. Strictly-necessary cookies are always on. You can change this any time via the "Cookie Settings" link in the footer.

  • Functional

    Remember preferences like dismissed banners and your dark-mode choice.

  • Analytics

    Help us understand how the site is used so we can improve it.

  • Marketing

    Measure our advertising and help us reach people who may be interested in Optuma.