AnsweredAssumed Answered

Nested IF statement - Pi Analytics

Question asked by JeremyMahon on Sep 1, 2016
Latest reply on Sep 1, 2016 by JeremyMahon

I have the following statement as a variable in a Pi Analytic:


if 'Gas PSI'>600 and 'Gas PSI'<750 and (if PrevVal('Gas PSI','*')<600 or PrevVal('Gas PSI','*')>750 then 1 else NoOutput()) then 1 else NoOutput()


When I Evaluate it, it returns no output as expected, because Gas PSI is currently over 1000 (I have a separate Analytic for Gas PSI>1000). My goal is to write a 1 when Gas PSI is within the range of 600-750 but ONLY if its previous value was either under 600 or over 750. The point is to record a 1 only when this threshold is crossed into the 600-750 range. Otherwise, if I don't filter out using the previous value, the analytic will continue recording 1s every time Gas PSI changes (even within the 600-750 range).


The problem is, when I back fill it, I get a bunch of Calc Faileds. I have a feeling my nested IF-OR statement is causing trouble... Must be something simple I am missing, but I think I've been working on Analytics so much in the last few days that I'm cross-eyed...


Thanks all!