locked
Compare Values object does not understand negative values? RRS feed

  • Question

  • I was trying to compare a value retrieved from a web service and make a simple value comparison. If <query result> is more than 0, log an event. The Policy Testing Console showed  me that -3.5 > 0 evaluated to TRUE...strange.

    I thought to myself, maybe it's not seeing this as a number at all. So to go a step further I typed the static value -3.5 and is greater than 0 still evaluates to TRUE.

    What am I missing here? I don't want to resort to PowerShell any more than necessary (which is the point here right?), but not feeling much choice.

    Are there any tips you can provide on how to best do simple integer comparisons in Opalis? (Precision is no greater than 2, and numbers all less than 100).

    Thursday, December 30, 2010 4:01 AM

Answers

  • The compare values object is not quite as precise as you would need for decimal numbers.

    You were correct to [sum({Published Data},0)] so that you can "promote" the string in the databus to a numeric number, this is the best way to go about doing this, in line (without the use of an extra object).

    One of these "extra objects" you could use as a workaround (for future reference) is the Query Database object, since you can just configure a connection to a database, yet just execute simple SQL queries: SELECT CASE IF {Published Data 1} > {Published Data 2} THEN 'TRUE' ELSE 'FALSE' END (or any standard IF...THEN query syntax)

    That said, there is another way to perform some decimal compares "in line". You can use the [diff()] function.

    In this example: [diff(10.002,10.001,3)]
    The result is: 0.001

    Alternatively in this example: [diff(10.001,10.002,3)]
    The result is: -0.001

    You still would not be able to use the compare values, but if the result of this [diff()] function is output available from an object (published data), you could use links to perform the comparison (less or greater than 0 depending on which way you look at it). Likely this would be as a result of using one of the "extra objects".

    The easiest way to perform numeric comparisons though, is using one of the "extra" objects and possibly evaluate based on the link coming from one of those. These objects again are:

    "Run .Net Script" Object (with C#, PowerShell, etc.)
    "Query Database"

    You can use the Data Manipulation functions in combination with these objects for maximum functionality.

    For your reference, the Data Manipulation Help is here: http://technet.microsoft.com/en-us/library/gg440683.aspx

    I hope this helps.

    Tuesday, January 18, 2011 11:42 PM
    Moderator

All replies

  • The Invoke Web Services activity doesn't return a numeric value.  It only returns strings.  How are you doing the numeric comparison?  Data returned on the databus is typed (data/time, integer, boolean, string, etc).  This is done to provide context to dialogues.  So the set of comparison options would be different for a string data type than would be the case for an integer data type.  If you are using "Compare Values" the default is to compare strings.  Click on "General" to change to compare numeric values.
    Monday, January 3, 2011 7:56 PM
  • I sent the output to a Compare Values object. I also suspected it was not returning a number, so I wrapped it in a SUM function and added it to zero to remove all doubt. Yes,  I did change it to numeric comparison. You actually don't get the numeric operators in the dropdowns unless you make that change.

    That  being said, how do I compare decimals in Opalis other than with Run .NET Script and PowerShell?

    Monday, January 3, 2011 10:01 PM
  • The compare values object is not quite as precise as you would need for decimal numbers.

    You were correct to [sum({Published Data},0)] so that you can "promote" the string in the databus to a numeric number, this is the best way to go about doing this, in line (without the use of an extra object).

    One of these "extra objects" you could use as a workaround (for future reference) is the Query Database object, since you can just configure a connection to a database, yet just execute simple SQL queries: SELECT CASE IF {Published Data 1} > {Published Data 2} THEN 'TRUE' ELSE 'FALSE' END (or any standard IF...THEN query syntax)

    That said, there is another way to perform some decimal compares "in line". You can use the [diff()] function.

    In this example: [diff(10.002,10.001,3)]
    The result is: 0.001

    Alternatively in this example: [diff(10.001,10.002,3)]
    The result is: -0.001

    You still would not be able to use the compare values, but if the result of this [diff()] function is output available from an object (published data), you could use links to perform the comparison (less or greater than 0 depending on which way you look at it). Likely this would be as a result of using one of the "extra objects".

    The easiest way to perform numeric comparisons though, is using one of the "extra" objects and possibly evaluate based on the link coming from one of those. These objects again are:

    "Run .Net Script" Object (with C#, PowerShell, etc.)
    "Query Database"

    You can use the Data Manipulation functions in combination with these objects for maximum functionality.

    For your reference, the Data Manipulation Help is here: http://technet.microsoft.com/en-us/library/gg440683.aspx

    I hope this helps.

    Tuesday, January 18, 2011 11:42 PM
    Moderator