PowerPivot Calculating Measure on semi-aggregated data

maxxam

New Member
Joined
Aug 13, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi all,

This forum has already helped me so much in the past months but now I have the first question I couldn't find an answer to anywhere else, really hope someone can point me into the right direction.

I have an Excel model where I use a data model and power pivot. Basically user enter the time they worked on a certain project (tblTimes) and there is target number of hours each user should work on a specific projet (tblAllottedTimes).

tblTimes
- Username
- Datestamp
- Project code
- Hours worked

tblAllottedTimes
- Username
- Projec code
- Hours planned

My goal: Create a pivot table with the following structure
Username | Project code | Sum of all hours worked | Number of hours planned | Remaining hours (basically the 4th column - 3rd column)

I succeeded in setting up the relationship between the two tables and create a pivot with the first 4 columns. The 5th however I don't know how to create since I can't create a calculated field when using power pivot.
Also to get the 4th column working I had to use a workaround where I added the Hours planned to the tblTimes via the RELATED function and then in the pivot instead of summing the "Hours planned" I let it show me the MAX value, maybe there is a better way.

So my best guess is that I need to write some kind of DAX function but I didn't find any similar question to orient myself on. Would love if someone could give me some advice.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Ideally you have a table with unique project codes. This table is then linked to both fact tables. The same for your usernames.
Then the following measures can be created:
Excel Formula:
Planned:=SUM(tblAllottedTimes[Hours Planned])
Worked:=SUM(tblTimes[Hours worked])
Remaining:=Planned-Worked

The pivot then takes project codes and usernames from the unique tables.
 
Upvote 0
Solution
Thanks for the feedback and mark. Glad I could help.
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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