If B19:B27 contains the value that defines the group, and you want E19 to contain the sum of D19:D27 for all rows having the same B value, use this formula in E19:
=SUMIF($B:$B,B19,$D:$D)
Then copy E19 down for the entire table.
For example, if B19:B27 all contain 1, Excel will add all corresponding values in column D where column B is 1 and place that total in E19. When you copy the formula down, B19 automatically changes to B20, B21, etc., while $B:$B and $D:$D remain fixed.
If you actually mean the repeated value in column A (64.65, 61.05, etc.) rather than column B (ni), then the formula should instead be:
=SUMIF($A:$A,A19,$D:$D)
Based on your screenshot, I suspect this second formula is what you want, because the repeated values are 64.65, 61.05, etc., while ni appears to be 1 for every row.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin