Forum Discussion
Multiplying Two Columns with Filters in Two Other Columns
- 2 years ago
Hello Syndicate_Admin ,
The first set to do this Calculation is to have both tabels with a relationship like the following:
With this you can create 3 measures to get your result (or even get everything with only one):
First create a measure that returns the total cost per employeeEmployeeCost = SUM(Employee[Cost per employee])Another measure for the Allocated Hours
AllocatedHours = SUM(Projects[Allocated Hours])Now, want you want is that, for every project, to do the product of both this measures and afterwards sum all of this produtcs. For this, in DAX, you need to use a iterator function like SUMX which has as first parameter a table to iterator from, and as second parameter a calculation to be applyed to each row of that table. In your case this should be the expression:
SUMX( 'Projects', [AllocatedHours] * [EmployeeCost] )This is the final outcome for the dataset provided
Here you can find a PowerBI file with this exercise : https://we.tl/t-FVD7xxpQXg
Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudo 👍
Thanks!
You can also check out my LinkedIn!
Best regards,
Jorge Pessoa
Wow @jpessoa8 !! Thanks a lot!!
I've been looking at the file and it looks really good.
I'm going to test your solution in my database, which is much larger, and if I have any problems, I'll post again.
Really, thank you so much!!