DAX - SUM in a calculated column

tiawy

New Member
Joined
Nov 30, 2014
Messages
11
Hi

How can I sum in a calculated column (not in a calculated measure)

If I for instance have the following table
EmployeeIDDateHourRegistration
101-01-20157
102-01-20155
103-01-20156
201-01-20153
202-01-20152
101-02-20157
102-02-20154
201-02-20153
202-02-20152

<tbody>
</tbody>

How do I make a Calculated Column that sums the total hours an employee as registered for the certain month. For instance EmployeeID 1 has registered a total of 18 hours for january 2015, so every row for employeeID 1 and a date in january 2015 should have 18 in this calculated column.


Like this:


EmployeeIDDateHourRegistrationEmployeeMonthTotal
101-01-2015718
102-01-2015518
103-01-2015618
201-01-201535
202-01-201525
101-02-2015711
102-02-2015411
201-02-201535
202-02-201525

<tbody>
</tbody>
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Must. Not. Ask. Why.

=CALCULATE(SUM(Table1[HourRegistration]), ALL(Table1), Table1[EmployeeId] = EARLIER(Table1[EmployeeId]))
 
Upvote 0
Hi scottsen


Thank you for the quick reply. The formula however gives me the following, which is grandtotal for each employee for all months.


I would like to see the total for each employee for each month


This is what I get with the formula:


EmployeeID Date HourRegistration EmployeeMonthTotal
1 01-01-2015 7 29
1 02-01-2015 5 29
1 03-01-2015 6 29
2 01-01-2015 3 10
2 02-01-2015 2 10
1 01-02-2015 7 29
1 02-02-2015 4 29
2 01-02-2015 3 10
2 02-02-2015 2 10


How do I extend the formula with date?


Thanks a lot!
 
Upvote 0
I guess you could make another column for Month =FORMAT(Table1[Date], "MM") and then do this

=CALCULATE(SUM(Table1[HourRegistration]), FILTER(Table1, Table1[EmployeeId] = EARLIER(Table1[EmployeeId]) && Table1[Month] = EARLIER(Table1[Month])))
 
Upvote 0

Forum statistics

Threads
1,216,172
Messages
6,129,290
Members
449,498
Latest member
Lee_ray

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top