PowerPivot - Calculated Columns within the table

Raghuraj

New Member
Joined
Apr 1, 2015
Messages
2
Hello,

I am new to PowerPivot and learning by hit and miss.

I have the following table.
DeptNameEmpCodeEmpNameStartDateEndDate
Dept AUK001John1/1/20133/30/2013
Dept BUK001John4/3/20135/4/2013
Dept AUK001John5/5/201411/15/2014
Dept CUK001John11/19/20142/7/2015
Dept DUK001John2/15/201512/30/2017
Dept BUK002Jane1/10/20145/30/2014
Dept CUK002Jane6/6/20143/1/2015
Dept AUK002Jane3/20/20154/30/2015
Dept DUK003Ria9/2/20141/5/2015
Dept CUK003Ria1/10/20156/30/2015
Dept BUK004Cindy1/1/20151/31/2015
Dept AUK004Cindy2/10/20153/14/2015
Dept DUK004Cindy3/15/20154/1/2015
Dept AUK004Cindy4/2/20155/30/2015
Dept CUK005Albert12/12/201412/30/2015

<tbody>
</tbody>
I am trying to create two calculated columns. First one to get the first assignment date of an employee, second one for first assigned department.

To get the first assignment date I used the below
Code:
CALCULATE(FIRSTDATE(Allocation[STARTDATE]),FILTER(ALL(Allocation),[EmpCode]=EARLIER([EmpCode])))
This seem to work and I get the desired result.

To get the department name, I am tried the below two options
Code:
[COLOR=#000000][FONT=Verdana]CALCULATE(VALUES([DeptName]),FILTER(ALL(Allocation),[EmpCode]=EARLIER([EmpCode]) && Allocation[STARTDATE] =[first assignment date]))))[/FONT][/COLOR]
OR
[COLOR=#000000][FONT=Verdana]LOOKUPVALUE([DeptName],[STARTDATE],[First Assignment date])[/FONT][/COLOR]

Both doesn't work and I am getting #ERROR. What am I doing wrong? How can i correct this?

Desired Result should be:
DeptNameEmpCodeEmpNameStartDateEndDateFirst Assignment DateFirst Assigned Department
Dept AUK001John1/1/20133/30/20131/1/2013Dept A
Dept BUK001John4/3/20135/4/20131/1/2013Dept A
Dept AUK001John5/5/201411/15/20141/1/2013Dept A
Dept CUK001John11/19/20142/7/20151/1/2013Dept A
Dept DUK001John2/15/201512/30/20171/1/2013Dept A
Dept BUK002Jane1/10/20145/30/20141/10/2014Dept B
Dept CUK002Jane6/6/20143/1/20151/10/2014Dept B
Dept AUK002Jane3/20/20154/30/20151/10/2014Dept B
Dept DUK003Ria9/2/20141/5/20159/2/2014Dept D
Dept CUK003Ria1/10/20156/30/20159/2/2014Dept D
Dept BUK004Cindy1/1/20151/31/20151/1/2015Dept B
Dept AUK004Cindy2/10/20153/14/20151/1/2015Dept B
Dept DUK004Cindy3/15/20154/1/20151/1/2015Dept B
Dept AUK004Cindy4/2/20155/30/20151/1/2015Dept B
Dept CUK005Albert12/12/201412/30/201512/12/2014Dept C

<tbody>
</tbody>

Thanks for your time!

Regards,
Raghu
PS: I couldnt figure out how to upload the sample file.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I just tweaked it a bit and it worked for my with the following.

=CALCULATE(VALUES(Allocation[DeptName]),FILTER(ALL(Allocation),[EmpCode]=EARLIER([EmpCode]) && Allocation[STARTDATE] =[first assignment date]))
 
Upvote 0
Thanks Kazlik.

But I am getting an error "A table of multiple values was supplied where a single value was expected.

But I tried to change it and it seems to be working now.

Revised as
Code:
[COLOR=#333333]=CALCULATE([/COLOR]FIRSTNONBLANK(Allocation[DeptName],1)[COLOR=#333333],FILTER(ALL(Allocation),[EmpCode]=EARLIER([EmpCode]) && Allocation[STARTDATE] =[first assignment date]))[/COLOR]

Thanks a lot!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,052
Messages
6,128,511
Members
449,455
Latest member
jesski

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