Razvan Mihai
Razvan Mihai

Reputation: 23

PowerBI new column calculation based on columns from different tables

I am trying to calculate 'TimeSheet Team PV'[Time (h)] * 'Position History'[Salary]

Data model: enter image description here TimeSheet Team PV" table: enter image description here "Position History" table: enter image description here

In the Position History table, I have some employees which were promoted and appear as having different periods during different periods in the company, with different salary. Can I join somehow these values based on Start Date, End Date (Position History table) and Work Date (TimeSheet Team PV tables) + Name?

I would like to generate new column in the TimeSheet Team PV table, with the calculation above.

Upvotes: 0

Views: 50

Answers (1)

Alexis Olson
Alexis Olson

Reputation: 40204

You'll need to write some logic to make sure it uses the Work Date column. Something like this:

Cost =
VAR WorkDate = 'TimeSheet Team PV'[Work Date]
RETURN
    'TimeSheet Team PV'[Time (h)]
        * CALCULATE (
            SELECTEDVALUE ( 'Position History'[Salary] ),
            'Position History'[Start Date] <= WorkDate,
            'Position History'[End Date] >= WorkDate
        )

Upvotes: 1

Related Questions