Formula Syntax Help - InfoPath Dev
in

InfoPath Dev

Formula Syntax Help

Last post 03-04-2009 05:18 PM by Ian Dawson. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-04-2009 12:28 PM

    Formula Syntax Help

    Newbie Question:  Can anyone out there post an example of the proper syntax to use when using the "floor" function against multiple fields?   I need to determine the highest value form multiple fields, but I haven't figured out the proper syntax.

    Example:

             Field A = 4

             Field B = 2 

             Field C = 5

    floor(((Field A),(FieldB),(Field C)))

     Thanks,

     JC

     

    Filed under:
  • 03-04-2009 05:04 PM In reply to

    You cannot use floor() with multiple fields, nor would it make sense to.  floor() rounds down a single numerical value.

     What you seem to need is the max() function.  However, the max() function only accepts one XPath argument, so you have essentially two options:

    Put the numerical field in a repeating group and reference it by its path:

    So if I have a data source like this:

    myFields
       group1
           group2 (repeating)
                valueNode

    I would use the formula   xdMath:Max(/my:myFields/my:group1/my:group2/my:valueNode)

    Arrange the data source so the value fields all have the same name, and use a more general XPath expression:

    So if the data source is like this:

    myFields
       group1
          valueNode
       group2
          valueNode
       group3
          valueNode

    I could use the formula   xdMath:Max(/my:myFields//my:valueNode)

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-04-2009 05:18 PM In reply to

    • Ian Dawson
    • Top 50 Contributor
      Male
    • Joined on 01-01-2009
    • Shellharbour NSW Australia
    • Posts 154

    Hi JC,

    Floor to seems to be a bit like a truncate function in EXCEL. It returns the largest integer below the value you enter.

    So that for    floor(34.765) = 34. 

    And the same applies to a variable, or formula like the age formula below.
    When the program is run it will return the next integer value below.

    Only one argument can be inserted.

    floor((number(substring(today(), 1, 4)) +
                number(substring(today(), 6, 2)) / 12 +
                number(substring(today(), 9, 2)) / 365.25) -
              (number(substring(@emplye_dob, 1, 4)) +
                number(substring(@emplye_dob, 6, 2)) / 12 +
                number(substring(@emplye_dob, 9, 2)) / 365.25))

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.