Convert Decimals to Text using Concat - InfoPath Dev
in

InfoPath Dev

Convert Decimals to Text using Concat

Last post 02-23-2013 07:58 PM by moldar. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 01-29-2013 08:31 AM

    Convert Decimals to Text using Concat

    Hi,

    Sorry if this has already been asked - I tried searching but couldn't find a similar post.

    I am using InfoPath 2010 to try and Concat fields from a Repeating Table into a single text box. The fields in the table are OutlayDescription, Currency and OutlayCost.

    I then have set the Value of the Concat field to :

    eval(eval(Outlay_Details, 'concat(my:OutlayDescription, " - ", my:Currency, my:OutlayCost, "
    ")'), ".."

     The issue I have is that the OutlayCost Field in the Repeating table is a Decimal Value set to show 2 decimal places. When this is converted to the Text Field it then drops the two blank decimals.

    ie. 50.00 in the Repeating Field becomes 50 in the Concat Field.

    Any idea how I can set the value to format to 2 decimal place?

    Thanks

    Tughsol

  • 02-14-2013 03:42 AM In reply to

    Re: Convert Decimals to Text using Concat

    Any ideas?
  • 02-14-2013 07:44 AM In reply to

    Re: Convert Decimals to Text using Concat

    Can you set the field to a decimal data type so you can set the format on it? If not, can you use an expression box (calculated value) instead?

    Hilary Stoupa

  • 02-15-2013 03:10 AM In reply to

    Re: Convert Decimals to Text using Concat

    Hi Hilary. Thanks for getting back to me!

    The field in the Repeating Table (OutlayCost) is set to a decimal data type but the field (OUTLAY_COMP) that is set to Concat the OutlayDescription, Currency and OutlayCost is a text field. This is because the OutlayDescription and Currency are text so a deciaml data type wouldn't accept it.

    I can change the Concat field (OUTLAY_COMP) to be a calculated value field but I'm not sure what the value should be then?

    The 3 things to consider are whether it needs .00, 0 or as it is.

    ie. If OutlayCost = 50.00 then it will appear as 50 in the concat text field. We need to add .00 to this.

    If OutlayCost = 50.10 then it will appear as 50.1 in the concat text field. We need to add 0 to the end.

    If OutlayCost = 50.25 then it will appear as 50.25 in the concat text field. We dont need to add anything.

    Does this make sense? Any idea how I could do this?

    Many thanks for your help!

  • 02-15-2013 07:39 AM In reply to

    Re: Convert Decimals to Text using Concat

    I'm suggesting that you put a calculated value on your form and set it to display the value of OUTLAY_COMP. Then set the calculated value to display as decimal. Then set the format to display 2 decimal places.
    Hilary Stoupa

  • 02-18-2013 07:24 AM In reply to

    Re: Convert Decimals to Text using Concat

    Hi Hilary,

    I have tried using an Expression Box and formatting it as a Decimal and set to 2 decimal places. It doesn't seem to work though as it still drops the .00 when I tested it.

    I would probably need it to be a Text Box rather than an Expression Box anyway though - as I need to pass the data through to the Library Column.

    Any other ideas?

    Thanks

  • 02-18-2013 09:19 PM In reply to

    Re: Convert Decimals to Text using Concat

    You could still store the value in a main data source field, I'm just suggesting you use an expression box to display the data.

    I just tried this in a sample form, and the decimal displayed correctly in Filler - are you in Browser or Filler? What version? I've attached my sample here for you to try - save it locally, right click and select design to open and then you can preview & type a value in the text box to see how it is displayed in the expression box.

    Hilary Stoupa

  • 02-21-2013 02:22 AM In reply to

    Re: Convert Decimals to Text using Concat

    Hi Hilary,

    Thanks for that. This works ok for a single value. I'm using multiple values from a Repeating Table so when I use the Concat function this doesn't work. It then drops the 0 or .00 again.

    Any ideas?

    Thanks

  • 02-23-2013 07:58 PM In reply to

    • moldar
    • Not Ranked
    • Joined on 02-23-2013
    • Posts 4

    Re: Convert Decimals to Text using Concat

    You are going to have to check to see if the point (.) exists in the string and then check out the length of what remains after the point. There is no if..then..else method in XPath 1.0, but you might be able to use something like this

    http://stackoverflow.com/questions/971067/is-there-an-if-then-else-statement-in-xpath

    Check out the Becker method mentioned in this post.

    If it were me, I would probably calculate it with code on the on change event of the group.

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