sum of secondary data - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

sum of secondary data

Last post 02-12-2020 04:47 PM by erzon. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 02-10-2020 09:27 AM

    • erzon
    • Not Ranked
    • Joined on 08-02-2019
    • Posts 11

    sum of secondary data

     I have 5 fields that are coming from secondary data. They are all in numeric format. What I need to do is once the user select the items in the list it will check how many quantity of that items from field1 to field5 and add them together.

    I tried 1 field and it's working fine but when I sum all 5 fields like sum(field1) +sum(field2) it's not working. all of files include filter already if the items = items in other list.

    Is the anyway to fix this? 

  • 02-10-2020 11:09 AM In reply to

    I need more info. I don't know what "not working" means here - the number isn't what you expect? The formula returns an error? You can't get the formula editor to accept the formula? etc....
    Hilary Stoupa

  • 02-10-2020 01:02 PM In reply to

    • erzon
    • Not Ranked
    • Joined on 08-02-2019
    • Posts 11
    Hilary Stoupa:
    I need more info. I don't know what "not working" means here - the number isn't what you expect? The formula returns an error? You can't get the formula editor to accept the formula? etc....
    the correct total is not showing and it only compute the first field but the other field it seems ignored
  • 02-10-2020 01:59 PM In reply to

    Could I see a copy of your form? You can attach it under the Options tab in a reply.
    Hilary Stoupa

  • 02-11-2020 07:08 AM In reply to

    • erzon
    • Not Ranked
    • Joined on 08-02-2019
    • Posts 11

    Hilary Stoupa:
    Could I see a copy of your form? You can attach it under the Options tab in a reply.
     

    Sorry we are not allowed to upload anything but this is the default value of the field  sum(Quantity2[Items = Item2]) + sum(Quantity1[Items = Item1]) + sum(Quantity3[Items = Items3]) + sum(Quantity) or  

     

    sum(xdXDocument:GetDOM("COO Store")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Quantity2[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:Items = ../d:Item2]) + sum(xdXDocument:GetDOM("COO Store")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Quantity1[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:Items = ../d:Item1]) + sum(xdXDocument:GetDOM("COO Store")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Quantity3[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:Items = ../d:Items3]) + sum(../my:Quantity) 

     

    The problem the only first field with sum is the one showing as a result 

  • 02-11-2020 07:39 AM In reply to

    The reason you are getting only the first one is because the XPath is using absolute paths instead of relative paths. If the field is in the my:SharePointListItem_RW group, I'd try something like this: sum(xdXDocument:GetDOM("COO Store")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Quantity2[current()/../my:Items = ../d:Item2]) + sum(xdXDocument:GetDOM("COO Store")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Quantity1[current()/../my:Items = ../d:Item1]) + sum(xdXDocument:GetDOM("COO Store")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Quantity3[current()/../my:Items = ../d:Items3]) + sum(../my:Quantity)
    Hilary Stoupa

  • 02-12-2020 03:41 AM In reply to

    • erzon
    • Not Ranked
    • Joined on 08-02-2019
    • Posts 11

    Hilary Stoupa:
    The reason you are getting only the first one is because the XPath is using absolute paths instead of relative paths. If the field is in the my:SharePointListItem_RW group, I'd try something like this: sum(xdXDocument:GetDOM("COO Store")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Quantity2[current()/../my:Items = ../d:Item2]) + sum(xdXDocument:GetDOM("COO Store")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Quantity1[current()/../my:Items = ../d:Item1]) + sum(xdXDocument:GetDOM("COO Store")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Quantity3[current()/../my:Items = ../d:Items3]) + sum(../my:Quantity)
     

     

    oh my god this works perfectly. So i just need to add the current() code? 

  • 02-12-2020 09:01 AM In reply to

    Right. This in the XPath: xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW gets replaced by current()/.. which basically means "From this current node, go up the tree to the the repeating my:SharePointListItem_RW group, and find the my:Items node in that same group as I am in".
    Hilary Stoupa

  • 02-12-2020 04:47 PM In reply to

    • erzon
    • Not Ranked
    • Joined on 08-02-2019
    • Posts 11

    Hilary Stoupa:
    Right. This in the XPath: xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW gets replaced by current()/.. which basically means "From this current node, go up the tree to the the repeating my:SharePointListItem_RW group, and find the my:Items node in that same group as I am in".
     

     

    Thank you so much. This really help you save my day. 

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