Formula for adding different fields in total - InfoPath Dev
in

InfoPath Dev

Formula for adding different fields in total

Last post 06-22-2010 09:49 AM by C0oli0. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 06-22-2010 08:24 AM

    Formula for adding different fields in total

    Hello,

    I'm creating a timesheet for users to be using. I have everything set up right now, but wanted to add one little extra something which is the total hours worked for that week.
    I have it set up like this:

                             Monday         Tuesday           Wednesday       Thursday        Friday         Saturday        Sunday
                                7                     7                          7                     7              7                     0                 0

    Total                                                                                                                                                    =35Here

    What kind of formula do i set it so it adds the total together of all the days? If it doesnt work that way, i wouldnt mind putting the total beside the Sunday as well if there is a formula for that as well?

    TY.

    Filed under:
  • 06-22-2010 08:48 AM In reply to

    Re: Formula for adding different fields in total

    Hi:

    Do you have different fields for each day of the week? You can simply add them together in a formula (use an expression box to display the formula). If they are all the same repeating field (my:Hours, for example), you should be able to use the sum function: sum(my:Hours). Here's an Office Online article with some additional info.

    Hilary Stoupa

  • 06-22-2010 09:17 AM In reply to

    Re: Formula for adding different fields in total

    When you say different fields do you mean different names? I'm using a text box for each day and with different names. It's the regular with field1 field2 etc.

     How do i use the sum function? Do i have to set the data type to number? or text?  And what's the value? If it's set to numbers it wont allow me to use anything but numbers...
    I'm using text box for all of them...

  • 06-22-2010 09:23 AM In reply to

    Re: Formula for adding different fields in total

    Hi Hilary,

     I copied each text box to have the same field name which was field9. I noticed when i would enter numbers or letters, all the other fields would copy it and i cant have that as people dont always work the same hours.

    But tried the sum(field9) formula, but it didn't work as it just showed sum(field9) in the text box...

    Any other ideas?

  • 06-22-2010 09:28 AM In reply to

    Re: Formula for adding different fields in total

    If they're in separate fields, you can probably just add together their values with a plus symbol.  Click the fx button to open the formula editor, and use the buttons there to select and insert the fields.  You'll wind up with something.

    field1 + field2 + field3

    etc.

     Incidentally, I would suggest using more descriptive names for your fields.  It could be a big help to you later on.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 06-22-2010 09:35 AM In reply to

    Re: Formula for adding different fields in total

    I'm attaching a sample for you to look at, perhaps that will help. You want to enter default value formulas using the "fx" button, so that they are added in the formula editor.

    Right click the link to the file in the header of this post. Save the file locally. Right click the saved file, and select Design to open the file up in design mode in InfoPath. You'll get a warning that you can ignore. Preview the form to see it.

    The template is for IP 2007 -- if you are using 2003, please let me know, and I'll save it in that format.

    Hilary Stoupa

  • 06-22-2010 09:49 AM In reply to

    Re: Formula for adding different fields in total

    OMG you guys freakin ROCK.

    I didn't know we had to add my in it, without it it just wouldnt work, but now it's working.

     

    TY TY TY TY.

    I'd have been finished without all of your helps!

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