Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
mgavin
New Member

Measure based on value at selected time.

Hi,

 

I am pretty new to Power BI and tasked with creating an employee dashboard to track current annual goal status. These goals are dependant on position and are converted to a score of 3, 2, or 1. Promotions happen once per year. I have been unable to figure out a solution to account for the position at the time of the date to affect the calculation.

 

Currently, the table just contains employee and position.

NamePosition
Employee APosition 1
Employee BPosition 1
Employee CPosition 1
Employee DPosition 1
Employee EPosition 2

 

I was successfully able to use these nested if statements to check the employee's position and calculate the score based on the appropriate goals for the table above.

 

 

 

 

 

SCORE_1 = 
VAR CurrentValue = SELECTEDVALUE('Employees'[Position])
RETURN

IF(
    //Check Position 1
    CurrentValue = "Position 1",
    //IF True, calculate score
    (IF(
        [Average 1] >= 0.985,
        3,
        IF(
            [Average 1] >= 0.98,
            2,
            1)
        )
    ),
    //IF False, Check Position 2
    IF(
        CurrentValue = "Position 2",
        //IF True, calculate score
        (IF(
            [Average 1] >= 0.99,
            3,
            IF(
                [Average 1] >= 0.985,
                2,
                1)
            )
        ),
        //IF False, check Position 3
        IF(
            CurrentValue = "Position 3",
            //IF True, calculate score
            (IF(
                [Average 1] >= 0.995,
                3,
                IF(
                    [Average 1] >= 0.99,
                    2,
                    1)
                )
            ),
            //IF False, return 0
            0
        )
    )
)

 

 

 

 

DateEmployeeAverage 1
1/1/2025Employee A0.988
1/1/2025Employee B0.99
1/1/2025Employee C0.97
1/1/2025Employee D0.983
1/1/2025Employee E0.987
2/1/2025Employee A0.988
2/1/2025Employee B0.99
2/1/2025Employee C0.97
2/1/2025Employee D0.983
2/1/2025Employee E0.987

 

 

To allow for historical data, I need to calculate their scores based on their position at the time by adding effective dates to the table.

NamePositionEffective Date
Employee APosition 12/1/2024
Employee BPosition 12/1/2024
Employee CPosition 12/1/2024
Employee DPosition 12/1/2024
Employee EPosition 22/1/2024
Employee APosition 22/1/2025
Employee BPosition 12/1/2025
Employee CPosition 12/1/2025
Employee DPosition 22/1/2025
Employee EPosition 32/1/2025

 

I am struggling to capture the score based on the employee's position at the time. I've tried adding a SELECTEDVALUE date with no success. Going back prior to the latest date displays no data, and leaving it as current changes historical data when their position changes. 

 

The desired outcome would be as follows where the position change occurring 2/1/2025 updates the calculation only after that date:

DateEmployeeAverage 1Score
1/1/2025Employee A0.9883
1/1/2025Employee B0.993
1/1/2025Employee C0.971
1/1/2025Employee D0.9832
1/1/2025Employee E0.9872
2/1/2025Employee A0.9882
2/1/2025Employee B0.993
2/1/2025Employee C0.971
2/1/2025Employee D0.9831
2/1/2025Employee E0.9871

(The same scores become lower based on higher goals associated with promotion on 2/1/2025, but remain the same score for prior to that date to reflect previous position).

 

Currently, updating the Employees table to reflect the new positions without a date would result in different scores as it uses the most recent position for all calculations:

DateEmployeeAverage 1Score
1/1/2025Employee A0.9882
1/1/2025Employee B0.993
1/1/2025Employee C0.971
1/1/2025Employee D0.9831
1/1/2025Employee E0.9871
2/1/2025Employee A0.9882
2/1/2025Employee B0.993
2/1/2025Employee C0.971
2/1/2025Employee D0.9831
2/1/2025Employee E0.9871

 

I need calculations prior to 2/1/2025 to reflect the employee's position prior to the promotion, and data after 2/1/2025 to reflect the employee's current position so that historical data is maintained.

 

Any help would be greatly appreciated!

 

Thank you!

1 ACCEPTED SOLUTION
HiteshDataXpert
New Member

Create a Calculated Column to Determine the Correct Position

In the scores table, create a calculated column to determine the employee's position at the time of the score. This column will use the Effective Date to find the correct position.

DAX
 
PositionAtDate = 
VAR CurrentDate = 'Scores'[Date]
VAR CurrentEmployee = 'Scores'[Employee]
RETURN
    CALCULATE(
        MAX('Employees'[Position]),
        FILTER(
            'Employees',
            'Employees'[Name] = CurrentEmployee &&
            'Employees'[Effective Date] <= CurrentDate
        )
    )

Update the Score Calculation

Modify your SCORE_1 measure to use the PositionAtDate column instead of the static Position column.

DAX
SCORE_1 = 
VAR CurrentPosition = SELECTEDVALUE('Scores'[PositionAtDate])
VAR CurrentAverage = SELECTEDVALUE('Scores'[Average 1])
RETURN
    SWITCH(
        TRUE(),
        CurrentPosition = "Position 1" && CurrentAverage >= 0.985, 3,
        CurrentPosition = "Position 1" && CurrentAverage >= 0.98, 2,
        CurrentPosition = "Position 1", 1,
        CurrentPosition = "Position 2" && CurrentAverage >= 0.99, 3,
        CurrentPosition = "Position 2" && CurrentAverage >= 0.985, 2,
        CurrentPosition = "Position 2", 1,
        CurrentPosition = "Position 3" && CurrentAverage >= 0.995, 3,
        CurrentPosition = "Position 3" && CurrentAverage >= 0.99, 2,
        CurrentPosition = "Position 3", 1,
        0
    )

View solution in original post

2 REPLIES 2
HiteshDataXpert
New Member

Create a Calculated Column to Determine the Correct Position

In the scores table, create a calculated column to determine the employee's position at the time of the score. This column will use the Effective Date to find the correct position.

DAX
 
PositionAtDate = 
VAR CurrentDate = 'Scores'[Date]
VAR CurrentEmployee = 'Scores'[Employee]
RETURN
    CALCULATE(
        MAX('Employees'[Position]),
        FILTER(
            'Employees',
            'Employees'[Name] = CurrentEmployee &&
            'Employees'[Effective Date] <= CurrentDate
        )
    )

Update the Score Calculation

Modify your SCORE_1 measure to use the PositionAtDate column instead of the static Position column.

DAX
SCORE_1 = 
VAR CurrentPosition = SELECTEDVALUE('Scores'[PositionAtDate])
VAR CurrentAverage = SELECTEDVALUE('Scores'[Average 1])
RETURN
    SWITCH(
        TRUE(),
        CurrentPosition = "Position 1" && CurrentAverage >= 0.985, 3,
        CurrentPosition = "Position 1" && CurrentAverage >= 0.98, 2,
        CurrentPosition = "Position 1", 1,
        CurrentPosition = "Position 2" && CurrentAverage >= 0.99, 3,
        CurrentPosition = "Position 2" && CurrentAverage >= 0.985, 2,
        CurrentPosition = "Position 2", 1,
        CurrentPosition = "Position 3" && CurrentAverage >= 0.995, 3,
        CurrentPosition = "Position 3" && CurrentAverage >= 0.99, 2,
        CurrentPosition = "Position 3", 1,
        0
    )
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors