Forum Discussion
Assign Department from Audit Table
- 6 years ago
Hi, pedanticpad
Based on your data, you may create two calculated columns in 'Clock' table as follows.
COSTCODE = CALCULATE ( MAX ( 'Audit'[NewValue] ), FILTER ( 'Audit', 'Audit'[UserID] = 'Clock'[UserID] && 'Audit'[ChangeType] = "COSTCODE" && 'Audit'[ChangeDate] = CALCULATE ( MAX ( 'Audit'[ChangeDate] ), FILTER ( 'Audit', 'Audit'[ChangeDate] <= 'Clock'[Date] && 'Audit'[UserID] = 'Clock'[UserID] ) ) ) ) DEPARTMENT = CALCULATE ( MAX ( 'Audit'[NewValue] ), FILTER ( 'Audit', 'Audit'[UserID] = 'Clock'[UserID] && 'Audit'[ChangeType] = "DEPARTMENT" && 'Audit'[ChangeDate] = CALCULATE ( MAX ( 'Audit'[ChangeDate] ), FILTER ( 'Audit', 'Audit'[ChangeDate] <= 'Clock'[Date] && 'Audit'[UserID] = 'Clock'[UserID] ) ) ) )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi v-alq-msft,
When I perform the pivot I get the below error;
There are alot of NULL values in the CHANGETYPE and NEWVALUE fields. I think the merge is only pulling in the data for an exact match and the other dates for each user is left as NULL.
I need to apply the department and cost code to every clock date so that for every clock before 05/01/2019 Department = Stores and CostCode = Store1, then for every clock from 02/25/2020 Department =Shipping and CostCode = Dock1. Any advice?
Thanks!
Hi, pedanticpad
I wonder the result of the last step before pivotting. Here is my result before pivotting.
If you have null in one column, you can click 'more options', choose what you want to filter.
Best Regards
Allan
- pedanticpad6 years agoHelper II
Hi v-alq-msft ,
See below step before the pivot;
I tried to filter out the null values but I got the below after pivoting;
Error;
Is the issue maybe that I am trying to do this against all employees not just one like in the example I gave?