cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SoulCuber
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!

 

powerbiexample.png

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

hello @SoulCuber

 

This give you the solution

 

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

 

😃




Lima - Peru

View solution in original post

5 REPLIES 5
madhuradighe
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

 

Capture.PNG

Vvelarde
Community Champion
Community Champion

hello @SoulCuber

 

This give you the solution

 

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

 

😃




Lima - Peru

Hi Victor,

 

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

 

Recuerdas de Holanda,

 

Jeroen

DSimma
Advocate II
Advocate II

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)

SoulCuber
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. 

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors