Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Calculation by using values from two different datasets

Hello all,

 

I am new on PowerBI and I started to work on DAX recently. I have a question regarding a formulation in PowerBI.

 

I have two datasets as below:

 

NameYearMonthHours
John Doe2018August20
John Doe2018September15

 

NameYearMonthCharge-out rate
John Doe2018August£22.00
John Doe2018September£20.00

 

What I'm trying to calculate is the monthly revenue of one person, which means that the formula will calculate John Doe's monthly revenue like this:

 

NameYearMonthRevenue
John Doe2018August£440.00
John Doe2018September£400.00

 

The formula needs to check the "Name", "Year" and "Month" in both datasets and needs the calculate the revenue by multiplying the rate with hours based on the conditions above.

 

Much appreciated if you could share your thoughts on this.

 

Thank you and Best regards,

Ugur

  • Anonymous's avatar
    Anonymous
    7 years ago

    Anonymous,

    You can create the following columns in your second table.

    Column = LOOKUPVALUE(Table2[Hours],Table2[Name],Table3[Name],Table2[Year],Table3[Year],Table2[Month],Table3[Month])
    revenue = Table3[Charge-out rate]*Table3[Column]



    Regards,
    Lydia

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello all,

     

    I am new on PowerBI and I started to work on DAX recently. I have a question regarding a formulation in PowerBI.

     

    I have two datasets as below:

     

    NameYearMonthHours
    John Doe2018August20
    John Doe2018September15

     

    NameYearMonthCharge-out rate
    John Doe2018August£22.00
    John Doe2018September£20.00

     

    What I'm trying to calculate is the monthly revenue of one person, which means that the formula will calculate John Doe's monthly revenue like this:

     

    NameYearMonthRevenue
    John Doe2018August£440.00
    John Doe2018September£400.00

     

    The formula needs to check the "Name", "Year" and "Month" in both datasets and needs the calculate the revenue by multiplying the rate with hours based on the conditions above.

     

    Much appreciated if you could share your thoughts on this.

     

    Thank you and Best regards,

    Ugur

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    I would create a column in each table that concatenates those three columns. Then you can relate the two tables (not datasets) to one another and then the measure is very simple to create, just SUM([Hours]) * SUM([Revenue]) essentially.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous,

    You can create the following columns in your second table.

    Column = LOOKUPVALUE(Table2[Hours],Table2[Name],Table3[Name],Table2[Year],Table3[Year],Table2[Month],Table3[Month])
    revenue = Table3[Charge-out rate]*Table3[Column]



    Regards,
    Lydia