Hi All,

I feel that what I am doing with my code here is really bad practice, or at least it feels that way.

I am working on a project which will be calculating peoples salary on a weekly basis, based on hours worked they will be paid overtime etc...

I am performing a join/group by then summing multiple colummns together. However, I am performing calculations inside of the group by, which feels wrong to me. I am wanting to know if theres a way of adding the summed columns together in a different manner to how I am performing it?

There are 4 different types of overtime payment in the month detailed below, which are Basic, Voluntary, extended and Other

```
```
HoursOnBankHolidayW3 = pg.Sum(x => x.ShiftDate >= vStart3 && x.ShiftDate <= weekThree ? x.Basic : 0)
+ pg.Sum(x => x.ShiftDate >= vStart3 && x.ShiftDate <= weekThree ? x.Voluntary : 0)
+ pg.Sum(x => x.ShiftDate >= vStart3 && x.ShiftDate <= weekThree ? x.Other : 0)
+ pg.Sum(x => x.ShiftDate >= vStart3 && x.ShiftDate <= weekThree ? x.ExtendedHours : 0) > 2250
? pg.Sum(x => x.ShiftDate == weekThree ? x.Voluntary : 0)
+ pg.Sum(x => x.ShiftDate == weekThree ? x.ExtendedHours : 0)
+ pg.Sum(x => x.ShiftDate == weekThree ? x.Other : 0)
+ pg.Sum(x => x.ShiftDate == weekThree ? x.Basic : 0) : 0,
```
```

So, the code above is being performed inside a group by query, I am checking if the summed hours in week 3 are greater than 2250 minutes (37.5) hours and if so, Sum the following values. This seems really cumbersome. and im wondering if theres a neater way to sum multiple columns and perform a calculation other than the above.