Hi Cedric
You might try using the reference to create a variable with that reference (cfr. Variables with variable names (eg fiscal parameters))
Everytime the same reference is used, add the value of that row to the variable with the reference.
At the bottom of the page you can then show the total of the variable.
Hopefully this helps.
Kind regards
Sam