Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
6 replies Latest Post - ‏2013-11-08T08:40:55Z by gopiTX
Rshya
Rshya
21 Posts
ACCEPTED ANSWER

Pinned topic How to change a value from .275 to 2.75 in WTX??

‏2013-10-28T18:35:39Z |

Hi All,

 

I have a doubt here, i have an interest rate has .2750000 in the input file and i need to show it as 2.75 in the output. How do I do this in WTX?? Please help me with this.

 

Thanks,

Rshya.

  • vijji_WTX
    vijji_WTX
    124 Posts
    ACCEPTED ANSWER

    Re: How to change a value from .275 to 2.75 in WTX??

    ‏2013-10-29T07:01:01Z  in response to Rshya

    This would be very bad solution..i guess.

    Interestrate=".2750000"

    LEFT(TRIMRIGHT(WORD(interestrate, '.', 2)),1)+"."+MID (TRIMRIGHT(WORD(interestrate, '.', 2)),1), 2,size(TRIMRIGHT(WORD(interestrate, '.', 2))))

     

    Any better solutions welcome

    Updated on 2013-10-29T07:11:51Z at 2013-10-29T07:11:51Z by vijji_WTX
    • Rshya
      Rshya
      21 Posts
      ACCEPTED ANSWER

      Re: How to change a value from .275 to 2.75 in WTX??

      ‏2013-11-04T20:26:04Z  in response to vijji_WTX

      Thanks vijji_WTX for your response. But the below code worked for me:

      IF(MID(LEFT(RIGHT(TRIMRIGHT(interestRate Comp:In1), 6), 1) + "." + RIGHT(TRIMRIGHT(interestRate Comp:In1), 5), 5, 1) = "0", LEFT(LEFT(RIGHT(TRIMRIGHT(interestRate Comp:In1), 6), 1) + "." + RIGHT(TRIMRIGHT(interestRate Comp:In1), 5), 4), LEFT(LEFT(RIGHT(TRIMRIGHT(interestRate Comp:In1), 6), 1) + "." + RIGHT(TRIMRIGHT(interestRate Comp:In1), 5), 5))

      So for ex: if input has .123400, it gave me 1.234

      If input had .123000, it gave me 1.23 also if input had .100000 it gave me 1.00. Unless the 3rd digit from the decimal is an actual value, it always gave me 1.00/2.99 format.

      Thanks for the idea from your code :)

      Thanks,

      Rshya

      • vijji_WTX
        vijji_WTX
        124 Posts
        ACCEPTED ANSWER

        Re: How to change a value from .275 to 2.75 in WTX??

        ‏2013-11-05T02:31:04Z  in response to Rshya

        Good to know this  and happy to see this "

        Thanks for the idea from your code :)

         

         

      • TarunB
        TarunB
        211 Posts
        ACCEPTED ANSWER

        Re: How to change a value from .275 to 2.75 in WTX??

        ‏2013-11-07T17:04:38Z  in response to Rshya

        I might be missing a trick here but -  why don't you just multiply the number by 10?

        • This reply was deleted by Rshya 2013-11-07T20:04:41Z.
        • Rshya
          Rshya
          21 Posts
          ACCEPTED ANSWER

          Re: How to change a value from .275 to 2.75 in WTX??

          ‏2013-11-07T20:05:49Z  in response to TarunB

          Very true TarunB...but I am trying to attain it  for a text field.

           

          Thanks,

          Rshya

          • gopiTX
            gopiTX
            8 Posts
            ACCEPTED ANSWER

            Re: How to change a value from .275 to 2.75 in WTX??

            ‏2013-11-08T08:40:55Z  in response to Rshya

            You can change that to text by using NUMBERTOTEXT function.

            Ex:

            NUMBERTOTEXT(Interestrate*10)

            Regards

            Gopi