March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
Register NowGet certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi there,
i would like to analyze project and department related hours and costs from a data set from my ERP system. I have loaded two tables into my PBI file.
Table 1:
Project Department Employee Date Work process Hours
X X X X X X
Table 2:
Department Hourly rate
X X
I created a Matrix which shows the sum of hours for each project and department. Now I would like to calculate the costs for each department taking into consideration the hourly rates contained in table 2.
I tried the LOKKUPVALUE DAX as below, but can only use static search values such as "Engineering" for example.
Solved! Go to Solution.
// This is the simplest solution
// but it can be slow if HourLedger
// is big because RELATED is
// doing a context transition for
// each and every row it operates
// on.
// There's a relationship
// Department[Department] 1:* HourLedger[Department].
// One-way filtering from the dimension to
// the fact table.
[Amount] =
SUMX(
HourLedger,
HourLedger[Hours] * RELATED( Department[HourlyRate] )
)
// This one will be more performant
[Total Hours] = SUM( HourLedger[Hours] )
[Amount] =
SUMX(
Department,
[Total Hours] * Department[HourlyRate]
)
// Bear in mind, though, that the column Department in HourLedger
// should be hidden and no slicing by it should take
// place. All slicing is always done through dimensions,
// never directly on a fact table.
Best
D
// This is the simplest solution
// but it can be slow if HourLedger
// is big because RELATED is
// doing a context transition for
// each and every row it operates
// on.
// There's a relationship
// Department[Department] 1:* HourLedger[Department].
// One-way filtering from the dimension to
// the fact table.
[Amount] =
SUMX(
HourLedger,
HourLedger[Hours] * RELATED( Department[HourlyRate] )
)
// This one will be more performant
[Total Hours] = SUM( HourLedger[Hours] )
[Amount] =
SUMX(
Department,
[Total Hours] * Department[HourlyRate]
)
// Bear in mind, though, that the column Department in HourLedger
// should be hidden and no slicing by it should take
// place. All slicing is always done through dimensions,
// never directly on a fact table.
Best
D
Hi darlove,
both ways working perfectly.
Thank you very much, great help. 👍
If you create a relationship One to Many on department, you can use the Related function within your SUMX expression to get the desired results.
Thanks for the quick responses.
Both tables are already related, but cannot solve it. I tried HR = sumx(Departments;RELATED( .....it will not propose any columns here)
I have multiple entries for each department in table 2, for example 3 for Engineering department. Will the sumx not result in 3 time the hourly rate of that department?
Thanks
Can you provide some sample data ?
Ricardo
Sorry I'm unable to upload files. How does it works?
You can paste the data here or upload the pbix using onedrive, googledrive, dropbox..
Ricardo
Try relating both tables and SUMX function.
So you can multiply the qty hours by hour rate in a measure.
Ricardo
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
Check out the November 2024 Power BI update to learn about new features.
User | Count |
---|---|
29 | |
20 | |
15 | |
14 | |
10 |
User | Count |
---|---|
62 | |
26 | |
25 | |
22 | |
15 |