Forum Discussion
Relationships determined by date
Im trying to produce a report to track timesheet entries and chargebility etc.
I have a data source of all timesheet entries, and a dataset with information relating to each employee, charge out rate, department, role etc. Both datasets have an Employee_ID for a relationship, this is fine.
I also have the ability to change the original Employee dataset to suit my needs.
I am struggling to find a way to relate these two datasets if there is a change in roles or department or any change in the Employees dataset. See below shows a role change on the 31/07/23, therefore any timesheet entry prior to that should be as a Data Manager, and anything after should be a Surveyor. But what ever the process, it need to be able handle multiple changes to the employee dataset over time. Ie a role changes multiple times over the year, the timesheet entries still need to relate to the role they were at at the time.
Im looking for suggestions on how to handles this, best way to set up the original Employee dataset, and best way to relate the two.
4 Replies
- AnonymousNot applicable
Hi NelsonRobinson ,
You can use the LOOKUPVALUE() function to create a calculated column.
RoleAtTime = LOOKUPVALUE( EmployeeHistory[Role], EmployeeHistory[Employee_ID], Timesheet[Employee_ID] )DepartmentAtTime = LOOKUPVALUE( EmployeeHistory[Department], EmployeeHistory[Employee_ID], Timesheet[Employee_ID] )If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- NelsonRobinsonRegular Visitor
See below link for example files.
https://BB.oper8cloud.com.au/invitations?share=ec490229468a75205b48
See the Example_Data.xlsx.
- The sheet 'STAFF DATA' is what i have a bit of power over the creation of, so suggestions on how to handle this would be good. This contains an EmployeeCode which does not relate to the timesheets. Note that any change happens to an employee, their EmployeeCode stays the same.
- The Empoyee_ID sheet is needed as an intermediate relationship. The STAFF_DATA has an EmployeeCode, and the TIMESHEETS, has an EmployeeID. The Employee_ID sheet has the relationship of these two.
- TIMESHEETS, ive added a couple weeks of data, and has EmployeeID for relation.
- Expectation. What i am trying to produce. Note the change in Role and other information to Ben Dawes, and Nelson Robinson
In the STAFF DATA you can see a change in information for Ben Dawes on the 14/7/2023, and a change for Nelson Robinson on the 24/7/2023. In my expectation sheet, you can see these changes take place on the correct dates.
Let me know if you need further clarification.
Table below showing expectation. Nelson Robinson Changed roles on 24/7/2023
TimesheetLineID Date StartTime StopTime Job EmpoyeeID PreferredName LastName EmployeeCode JobTitle Chargeability% Capability Notes 58654354 21/07/2023 7:00:00 AM 4:00:00 PM Job 3 25910 Nelson ROBINSON 1422 SURVEYOR 95 SiteMap 58654355 21/07/2023 7:00:00 AM 4:00:00 PM Job 4 25902 Max SCOTT 1461 PLANNER 50 Planning 58654356 24/07/2023 7:00:00 AM 4:00:00 PM Job 1 27277 Ben DAWES 1516 REGIONAL MANAGER 50 Corperate 58654357 24/07/2023 7:00:00 AM 4:00:00 PM Job 2 25841 Ash NAIDU 1157 ASSISTANT 0 SiteMAP 58654358 24/07/2023 7:00:00 AM 4:00:00 PM Job 3 25910 Nelson ROBINSON 1422 DATA MANAGER 50 SiteDE Nelson Robinson Changed roles here 58654359 24/07/2023 7:00:00 AM 4:00:00 PM Job 4 25902 Max SCOTT 1461 PLANNER 50 Planning 58654360 25/07/2023 7:00:00 AM 4:00:00 PM Job 1 27277 Ben DAWES 1516 REGIONAL MANAGER 50 Corperate 58654361 25/07/2023 7:00:00 AM 4:00:00 PM Job 2 25841 Ash NAIDU 1157 ASSISTANT 0 SiteMAP 58654362 25/07/2023 7:00:00 AM 4:00:00 PM Job 3 25910 Nelson ROBINSON 1422 DATA MANAGER 50 SiteDE
- NelsonRobinsonRegular Visitor
Sorry first time here, cant see how to attach files?
- AnonymousNot applicable
Hi NelsonRobinson ,
Refer to:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
Best Regards,
Neeko Tang