Adding spaces to numbers - InfoPath Dev
in

InfoPath Dev

Adding spaces to numbers

Last post 07-20-2014 05:59 PM by donstephen. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-17-2014 12:37 PM

    • KEV1N
    • Not Ranked
    • Joined on 07-17-2014
    • Posts 4

    Adding spaces to numbers

     I need to format a number like a UPC. The number is 12 characters (have a 14 character text box) and should be in the format 1 2345678912 3. I know I need something similar to the formula below inside of a rule, but do not understand what numbers go in place of the #.

     

    concat(substring(., #, string-length(.) - #), " ", substring(., string-length(.) - #, #), " ", substring(., string-length(.) - #, #))

  • 07-20-2014 05:59 PM In reply to

    Re: Adding spaces to numbers

    Hi Kevin,

    It would be difficult to explain this formula as a whole, but we can dissect the whole formula so it would be easier for you to understand.

    The whole formula is composed of three substring functions separated by spaces (" ").

    substring(text, starting position, character count)

    text represents which field you are taking the value from,
    the second value is the character count where the returned value will start from
    last value is the number of characters which will be returned starting from the

    using spaghetti as a sample word and a formula substring(field1, 4, 3), this formula will return a value of ghe since G is the fourth letter and from there, it will return 3 letters, in this case GHE.

    The first substring from you formula, the character count is represented by another formula which uses a string-length function with a subtraction operator. This would mean the total character count of the current field (represented by a dot), minus a value which can either be constant or dynamic if you will be using a field.

    substring(., #, string-length(.) - #)

    The second and third substring formulas are similar, however this time the string-length function is used for the character count where the returned value will start from.

    I hope this makes sense.

    Don Stephen Lambatin / Support Engineer
    Qdabra Software
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.