GroveStreams
Josephny private msg quote post Address this user
I use code that displays the moving 7 day average propane usage.

Unfortunately, whenever I get a tank fill up, the average gets messed up.

I use this code:

if(isNull(weekagopropane) || isNull(currentpropane), NULL, (weekagopropane-currentpropane)*10)

I tried the following but got an error on column 125 that I can't figure out:

if(isNull(weekagopropane) || isNull(currentpropane) || isNull(dayagopropane), NULL, (if((weekagopropane-currentpropane)<=1) , (dayagopropane-currentpropane)*10,(weekagopropane-currentpropane)*10)

Can someone please help me?

Thanks!
Post 1 IP   flag post
MThomas private msg quote post Address this user
I think you might be missing a parenthese for your very first parenthese.

Try:

if(isNull(weekagopropane) || isNull(currentpropane) || isNull(dayagopropane), NULL, (if((weekagopropane-currentpropane)<=1) , (dayagopropane-currentpropane)*10,(weekagopropane-currentpropane)*10))
Post 2 IP   flag post
MikeMills private msg quote post Address this user
Not sure if it helps, but you can plug it into an online Excel Formula Beautifier.

http://excelformulabeautifier.com/
Post 3 IP   flag post
Josephny private msg quote post Address this user
Quote:
Originally Posted by MThomas
I think you might be missing a parenthese for your very first parenthese.

Try:

if(isNull(weekagopropane) || isNull(currentpropane) || isNull(dayagopropane), NULL, (if((weekagopropane-currentpropane)<=1) , (dayagopropane-currentpropane)*10,(weekagopropane-currentpropane)*10))


Thank you for the help.

I tried that and received the following error:

"ERROR: 'Minutes per gallon/7 Days Propane Useage Total n-7': Stream Derivation Expression Error: 'Line 1 column 125: Function com.singularsys.jep.functions.If@5228cc7f: invalid number of arguments 1'."

It doesn't like "<=1"

I tried "<0" and it didn't like that either.

As if it was a type mismatch but from what I read that doesn't apply in this environment.
Post 4 IP   flag post
Josephny private msg quote post Address this user
Quote:
Originally Posted by MikeMills
Not sure if it helps, but you can plug it into an online Excel Formula Beautifier.

http://excelformulabeautifier.com/


Cool!

It might not help here (or it might), but it'll definitely help in many other situations.

Thanks!
Post 5 IP   flag post
MikeMills private msg quote post Address this user
The error is actually referring to the number of arguments in the "if" statement. I think your parenthesis are still messed up. Try this one

if(
    isNull(weekagopropane) || isNull(currentpropane) ||isNull(dayagopropane),
    NULL,
    if(
        ( weekagopropane - currentpropane ) <= 1,
        ( dayagopropane - currentpropane ) * 10,
        ( weekagopropane - currentpropane ) * 10 
    )  
)
Post 6 IP   flag post
Josephny private msg quote post Address this user
That did it!

And I learned how to use formatting to make the code so much more readable and error free!

Thank you!
Post 7 IP   flag post
Josephny private msg quote post Address this user
Well, I thought it worked because I didn't get the immediate error, but there's still a problem:




Post 8 IP   flag post
2968 8 8
Log in or sign up to compose a reply.