Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
How would you write a DAX formula for a new measure that would lookup a string value from another table that contains employee position information and a start/stop date of that position.
Bob - Date: 2/15/2020 (that date will fluctuate because the transactional data table is formatted on a daily basis, and would be between the start/end date in the employee position table)
What is his position: Should be Retail Associate
Employee Position Information
Employee | Position | Start Date | End Date |
Bob | Training Associate | 11/1/2019 | 1/7/2020 |
Bob | Retail Associate | 1/8/2020 | 6/15/2020 |
Bob | Retail Manager | 6/16/2020 | 12/31/2050 |
Expected outcome
Employee | Transaction Date | Sales | Expected Outcome |
Bob | 1/4/2020 | 3 | Training Associate |
Bob | 2/15/2020 | 4 | Retail Associate |
Bob | 3/16/2020 | 2 | Retail Associate |
Solved! Go to Solution.
@Anonymous, try this solution:
1. Create a star schema data model:
2. Create measure:
Position =
VAR vEmp =
MAX ( Employee[Emp ID] )
VAR vDate =
MAX ( EmployeeTransaction[Date] )
VAR vEmpTable =
FILTER (
ALL ( EmployeePosition ),
EmployeePosition[Emp ID] = vEmp
&& vDate >= EmployeePosition[Start Date]
&& vDate <= EmployeePosition[End Date]
)
VAR vPosition =
MAXX ( vEmpTable, EmployeePosition[Position] )
RETURN
vPosition
3. Result:
Proud to be a Super User!
@Anonymous, try this solution:
1. Create a star schema data model:
2. Create measure:
Position =
VAR vEmp =
MAX ( Employee[Emp ID] )
VAR vDate =
MAX ( EmployeeTransaction[Date] )
VAR vEmpTable =
FILTER (
ALL ( EmployeePosition ),
EmployeePosition[Emp ID] = vEmp
&& vDate >= EmployeePosition[Start Date]
&& vDate <= EmployeePosition[End Date]
)
VAR vPosition =
MAXX ( vEmpTable, EmployeePosition[Position] )
RETURN
vPosition
3. Result:
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |