Formula with where condition

Hi,

Is there a way to add : where group = ‘so and so’ condition using formula or automation.
Use case: I have a group called Milestone which has tasks as : Discovery, Planning, Design, Implementation, Closure. I have also groups with exact same names. I am trying to add the sum of planned effort in hours for each of these groups to the task in the milestone group.
Currently: I have to manually add the total planned effort for each task depending upon the group. There are boards where I have 20-25 groups and it becomes very tedious.
Expected: A way where I can add additional conditions (sum of planned efforts where group = ‘abc’ ) to further filter out the information and avoid manual interference.