Sum up several fields(but not hidden fields) - InfoPath Dev
in

InfoPath Dev

Sum up several fields(but not hidden fields)

Last post 06-14-2012 11:03 PM by HaiPeng. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-14-2012 07:07 PM

    Sum up several fields(but not hidden fields)

     Hello everyone,

     I have a several lists in individual sections posing as print-pages. If one lists reaches the set max number of rows, the next section(contianing the next lists) becomes visible. In the first section I want to have a field which gives the total of all the visible lists. If I set the field's value to add up all the lists numbers it adds the hidden ones, too.

    So my idea would have been to account for the hidden fields by subtracting those from the total and change the field's value es soon as the hidden sections get turned visible. However, setting a field's doesn't work. I think I would need to change the fields formular so that it'd keep updating itself. Does anyone know how to change a fields formular?

     Or is there a nicer, less convoluted solution?

    Filed under: , ,
  • 06-14-2012 07:35 PM In reply to

    Re: Sum up several fields(but not hidden fields)

    I wish I could better understand your phrase: 
    " I want to have a field which gives the total of all the visible lists" 

    A list is a set of fields (and rows, basically a table, and you want to have a total of all fields in a few lists?

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 06-14-2012 08:38 PM In reply to

    Re: Sum up several fields(but not hidden fields)

     Looking back, my post is quite unintelligible...

      I've added a simplified example.

     I have two sections with tables in it, a button and a invisible field called "SwitchPage". As long as "SwitchPage" has a value of 0, the second section is hidden. If you press the button, "SwitchPage" gets set to 1 and the second section appears.

    Now the repeating tables have two columns. The user will enter numbers in the second column. I want to add a "total sum"-field that displays the total of all the numbers added in the second column's fields. However, I don't want it to count the numbers in the second section as long as this section is hidden(or "SwitchPage" is set to 0 - same deal, really). This is a problem because both repeating table's number fields have a default value(in this case 5). So when I set my "total-sum" field to sum up all the fields in both second columns it will display 5 more than I initially want because it's already counting the value of the - as of yet - hidden field/table/section.

  • 06-14-2012 09:49 PM In reply to

    Re: Sum up several fields(but not hidden fields)

    In your case, this should do the trick:

    sum(field2) + sum(field5) * SwitchPage

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 06-14-2012 11:03 PM In reply to

    Re: Sum up several fields(but not hidden fields)

     Oooh!

    Of course... nice solution, thank you!

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