Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.