I have a formula @InitVars in the page header which includes the following, and similar lines:
shared numbervar runWaste:=0;
In Details v,
The problem is that @InitVars is in the page header, not the report header. It is resetting the variable to 0 at the top of every page.
Moving @InitVars to the report header fixed it so the correct number comes up in the sub-report in Details az.
I still see some odd behavior when I include the variable in the main report, but since that was just for debugging, not the main target, I don't care.