Thanks for the sample.

When I choose a different reason on rows 6 and 7 I get the correct figures in columns N and O, with the correct total so not sure I understand the issue.

In column P, you don't really need the =SUM(N5+05), just =N5+O5 would do