Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
2 years ago
Solved

Multiplying Two Columns with Filters in Two Other Columns

Hello! I'm an initiate on this subject and I'm pretty lost. Let's see if anyone can lend me a hand. I have 2 boards: 1. Hourly Cost Per Employee Table: Employee Cost per employee Jav...
  • jpessoa8's avatar
    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 employee

     

    EmployeeCost = 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