You are viewing limited content. For full access, please sign in.

Question

Question

Forms LT() Calculation returning wrong evaluation?

asked on May 20, 2021

Hello,

I am using Forms Professional Version 10.4.0.1256

I am trying to create a flag by assigning a value of "TRUE" or "FALSE" to a single-line field based on a calculation. Let's call this single line field "FLAG". FLAG does not have a default value set.

The calculation should take the number(not a string) of the current month (today's current month is May so May's number would be 5) and evaluate it against a set number (lets say 2). So if the current month's number is less than 2, then return true.

CURRENT_MONTH is calculated by using the calculation: =MONTH(TODAY())

 

The calculation that I am trying to use is Less Than or LT and would be written as:
FLAG =LT(CURRENT_MONTH, 2)

Replacing the CURRENT_MONTH variable with its value of 5, this would translate to:
FLAG =LT(5,2)
and should return "FALSE".

The issue that I am having is that the calculation above is returning "TRUE".

I have fiddled with this by switching the parameter order to:

  • =LT(2, CURRENT_MONTH)" (returns "TRUE" as it SHOULD since 2 is indeed less than 5)
  • =LT(6, CURRENT_MONTH)" (returns "TRUE" as it SHOULD NOT since 6 is NOT less than 5)
  • =LT(CURRENT_MONTH, 6)" (returns "TRUE" as it SHOULD since 5 is indeed less than 6)

So the FLAG variable seems to be hard set to "TRUE" so I tried assigning it a default value of "FALSE" but this did not work as FLAG kept getting updated to "TRUE".

Could it be that CURRENT_MONTH is receiving a "5" as a string and not a numeric literal and might be causing some comparison error against the numeric literal 2?

Thank you all for your time.

0 0

Answer

SELECTED ANSWER
replied on May 20, 2021

Solved.

The issue was in fact a conflict in comparing a string (CURRENT_MONTH) to a number (2).

Solution was to create a new CURRENT_MONTH variable but using a number field rather than a single-line field.

0 0
replied on May 20, 2021

The Number field route is definitely better to ensure it is numeric, but another thing you can use if you need it in the future is the VALUE() function.

VALUE() will try to convert a string to numeric, so the following should fix the issue when "Variable" is a numeric string.

=LT(VALUE(Variable), 2)

However, it would display a calculation error if the source string is non-numeric.

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.