I got this working using 4 formulas.
1: on the detail line iself. In this I increment 2 shared variables with the value of the item, once the item number is different from the Next(ItemNumber). (One for the group total and one for the grand total)
2: on the group footer. This increments the 2 shared variables if the NextIsNull(ItemNumber), since the previous won't take into account the last record.
3: on the report footer. This simply displays the grand total.
4: on the group footer again. In this I simply set the group total to 0 when the GroupNumber is not equal to Next(GroupNumber).
I don't know if this is the best way of doing it, but it's the only way I could seem to get it to work...