MySQL Formula not running

Post Reply
sgardner478
Posts: 51
Joined: 12 Sep 2020, 19:39
Name: Steve
Location: US Los Angeles

MySQL Formula not running

Post by sgardner478 »

I have a MySql Formula field and it stopped working after upgrade to 2.8.
Capture.JPG
It does not change the value when the values of [975] or [563] change. It used to work fine.

I changed the "IF" from capital to lower case and it did not make a difference. I reversed the order of the fields in the formula and that did not make a difference.
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: MySQL Formula not running

Post by support »

Fields [975] and [563] are entered?
sgardner478
Posts: 51
Joined: 12 Sep 2020, 19:39
Name: Steve
Location: US Los Angeles

Re: MySQL Formula not running

Post by sgardner478 »

Yes, there are values in those fields. One of the fields is current quantity of supplies and the other field is minimum required quantity. If current supply drops below minimum, then system alerts user to order more supplies. It was working in version 2.7.

The last column should change when quantity and minimum quantity columns change. The last column does not change. Notice that one item has lower quantity than required minimum and other item has higher quantity, however the last column shows "0" for either scenario.
Capture.JPG
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: MySQL Formula not running

Post by support »

Fields [975] and [563] are simple numeric fields?
Try to change formula to
if(([975]+0)>([563]+0),1,0)
sgardner478
Posts: 51
Joined: 12 Sep 2020, 19:39
Name: Steve
Location: US Los Angeles

Re: MySQL Formula not running

Post by sgardner478 »

Interesting..... that fixed it. It works now. I do not understand why adding 0 helps.
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: MySQL Formula not running

Post by support »

It's because numeric fields stored as varchar in database. I had target to allows enter empty value in number.
So if you compare two fields you compare strings. But if you add 0 then mysql compare numbers.
sgardner478
Posts: 51
Joined: 12 Sep 2020, 19:39
Name: Steve
Location: US Los Angeles

Re: MySQL Formula not running

Post by sgardner478 »

Thank you!
Post Reply