I have a requirement where I'm required to use the DataColumn.Expression Property syntax (link provided below) to essentially run some pretty complex equations, including some polynomial equations that if I don't put in some mix/max limits on them will go in some extremes we don't want. Essentially I have many nested IIF statements while trying to keep the polynomial equation going no higher than 200 or less than 70 all while moving into new temp value ranges. It would be nice if there is some type of min/max functions I could use within the .NET expression property syntax but I could find anything that would work for this. I know my syntax below isn't right either since its going to zero for the false side if the first expression fails if I'm reading this right. Any help or direction would be appreciated. Please let me know if need to explain any of this better. It's really hard to find any expanded resources on this syntax anywhere beyond this link below.
IIF([temp]>=0 and [temp]<20,
IIF((23+([duration]*6))-(0.4779*[temp])+(0.06755*([temp]^2))-(0.002237*([temp]^3))+(0.0001321*([temp]^4))<70, 70,
IIF((23+([duration]*6))-(0.4779*[temp])+(0.06755*([temp]^2))-(0.002237*([temp]^3))+(0.0001321*([temp]^4))>200, 200,
IIF([temp]>=0 and [temp]<20,
23+([duration]*6))-(0.4779*[temp])+(0.06755*([temp]^2))-(0.002237*([temp]^3))+(0.0001321*([temp]^4),
IIF([temp]>=0 and [temp]<25, 60,
IIF([temp]>=0 and [temp]<30, 50,
IIF([temp]>=0 and [temp]<35, 0,
IIF([temp]>=20,
IIF((33+([duration]*6))-(0.3779*[temp])+(0.04758*([temp]^2))-(0.0017*([temp]^3))+(0.000151*([temp]^4))<70, 70,
IIF((33+([duration]*6))-(0.3779*[temp])+(0.04758*([temp]^2))-(0.0017*([temp]^3))+(0.000151*([temp]^4))>200, 200,
IIF([temp]>=20,
33+([duration]*6))-(0.3779*[temp])+(0.04758*([temp]^2))-(0.0017*([temp]^3))+(0.000151*([temp]^4),
IIF([temp]>=0 and [temp]<25, 60,
IIF([temp]>=0 and [temp]<30, 50,
IIF([temp]>=0 and [temp]<35, 0,)))))), 0))))))), 0)