Max at one level and sum at another

I want to have the max of a value at a level and then sum at levels above,
I’m using the following:

However the result I’m getting is a sum at all levels instead of having a max at the first and then a sum

I also checked, if I replace the max with min or sum I get the same value