Hi RogerGH and welcome!
Thanks for uploading your XSN. I took a look at it. I think the problem is your schema. field5 should not be repeating. Instead, add a group4 under group3 and then put field5 under that. Group4 should be marked as repeating. Then, add an OnChange rule to each of field1, field2, field3, and field4 that sets the appropriate Group4 value. You'll need to hardcode the number: group4[1], group4[2], etc. in the xpath you use to set the value, but it should be easy to do. More generically, you could set up a copytable command using Qdabra's qRules. If you do that, you may want to change group3 to not be a child of group2.
Best of luck with your mission,
P