cancel
Showing results for
Did you mean:
Frequent Visitor

## Calculate column with subtotals

I would like to create a column/measure that computes the sum of one column for all distinct combinations of two other columns.

The example below shows hours per operator per date. The last column "Job hours" is the one I am looking for. I would like to calculate the sum of column "Hours" per distinct combination of "Date" & "Job". Can anyone help me how to calculate these subtotals? Many thanks!

1 ACCEPTED SOLUTION
Community Champion

hello @SoulCuber

This give you the solution

Job Hours = CALCULATE(Sum(Table1[Hours]),ALLEXCEPT(Table1,Table1[Date],Table1[Job]))

😃

Lima - Peru
5 REPLIES 5
Regular Visitor

Dears,

I'm stuck in getting below calculation; any help is much appreciated 🙂

I want to divide column C each row by the subtotal of column D

Cheers! MD

Community Champion

hello @SoulCuber

This give you the solution

Job Hours = CALCULATE(Sum(Table1[Hours]),ALLEXCEPT(Table1,Table1[Date],Table1[Job]))

😃

Lima - Peru
Frequent Visitor

Hi Victor,

Muchas gracias, functiona estupendo!! Great thanks, this was exactly what I was looking for!!!

Recuerdas de Holanda,

Jeroen

You can use the summarize function to create a new table from this table that is summarized on the first two columns with a sum of whatever other columns you want, or other functions.

ie somthing like table 2=summarize(table1, date, job, "Total Job Hours", Sum(Job Hours)

Frequent Visitor

Thanks a lot DSimma for your suggestion. That does indeed create the desired column, but in a different table. Which is indeed what I have done now. However, I would like to have the column in the original table. I guess I could link the summed column back into the original column by creating a new key column, but that is ugly. I wondered if there would be a formula for it.

Announcements