The summary field and budget both display correctly,
I suspect that you are putting the summary field in a sub summary layout part? That will compute a subtotal, but when you refer to the summary field in a calculation, the summary field computes a grand total--a total based on the current found set.
If that is correct, getSummary ( TotalCost ; BreakField ) can return the sub total. You specify the same "break field" as you do the "when sorted by" field for the sub summary part.