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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ALemmy
Frequent Visitor

lookup an employee and return role based on date entry was made

Hi gang 

 

I have been trolling through as many questions as I can and you have been super helpful before so maybe someone can help me again 🙂

 

I have two tables in a larger data set 

 

Table 1: 

Has all time entries submitted by all employees (EMPLID) and the date the entry was made (TRANSDATE) 

 

Table 2: 

Role table with start and end date of roles and promo's 

 

The EMPLID will be duplicated in the EMPLID column if the person has had a 'role name' change in the system - each change is time stamped, the start (CREATED) and end date (Latest date) of the role are next to each occurance of the EMPLID in table 2.

 

*if the role hasnt been edited it will return todays date in latest date

ALemmy_0-1609781417387.png

 

What I need to do is look up the EMPLID in table 1 and TRANSDATE table 1 and match it to the correct role NAME for that EMPLID in table 2. 

 

I used to have a lookup formula that worked fine when I didnt have EMPLID duplications in table 2 so now I need to implement this change to keep track of changing roles in a project and implement the right rate throughout the life of it. 

 

If anyone can give me any pointers it would really help 🙂 

 

Thank you all and HAPPY NEW YEAR 

Anne

 

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@ALemmy try this as a new column in your task table, change col and table name as per your model.

 

Role = 
VAR __taskDate = Tasks[TaskDate]
VAR __empId = Tasks[EmpId]
RETURN
CALCULATE ( 
    LASTNONBLANK ( Emp[Role], TRUE() ), 
    __empId = Emp[EmpId],
    __taskDate >= Emp[Start],
    __taskDate <= Emp[End]
) 

 

Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@ALemmy Appreciate the feedback and glad it worked out. I would like to say, you explained your problem very well, and it was fun to work with. Cheers!!

 

Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@ALemmy try this as a new column in your task table, change col and table name as per your model.

 

Role = 
VAR __taskDate = Tasks[TaskDate]
VAR __empId = Tasks[EmpId]
RETURN
CALCULATE ( 
    LASTNONBLANK ( Emp[Role], TRUE() ), 
    __empId = Emp[EmpId],
    __taskDate >= Emp[Start],
    __taskDate <= Emp[End]
) 

 

Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

THANK YOU SO MUCH ... honestly and your break down is super helpful to understand 

 

be blessed 

 

Anne

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors