Forum Discussion
How to capture corresponding manager ID based on transaction date if manager keeps changing
- 6 years ago
Hello friend_anand
You may use the following DAX post creating relationship between the two tables:
ManagerID = CALCULATE ( VALUES ( dtEmployee[MGR ID] ), FILTER ( RELATEDTABLE ( dtEmployee ), dtTransaction[TRAN DATE] >= dtEmployee[START DATE] && dtTransaction[TRAN DATE] <= IF ( ISBLANK ( dtEmployee[END DATE] ), TODAY (), dtEmployee[END DATE] ) ) )Regards,
Vivek
If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂
https://www.vivran.in/ - 6 years ago
Hellofriend_anand
I have validated the formula with the conditions you have mentioned:
For Manger 1, the date range is the same for Emp 1 & Emp 2
EMP 1
EMP 2
Have you created the relationship between these two tables?
In this case, it would be many-to-many with bi-directional filters
Regards,
Vivek
Hi Vivek,
I just notice that if the date range is same for 2 EMP ID's, then it returns blank in the MGR ID.
It should actually pick the corresponding MGR ID based on the EMP ID. However, in the DAX you provided, I am not sure if it checks the EMP ID anywhere. Please check and advise.
Thanks, Anand
- vivran226 years ago
Community Champion
Hellofriend_anand
I have validated the formula with the conditions you have mentioned:
For Manger 1, the date range is the same for Emp 1 & Emp 2
EMP 1
EMP 2
Have you created the relationship between these two tables?
In this case, it would be many-to-many with bi-directional filters
Regards,
Vivek
- friend_anand6 years agoNew Member
Yes, it works now.. I think there was an issue in the relationship.. I set it right now..
Thanks again, Vivek