Forum Discussion
pedanticpad
6 years agoHelper II
Assign Department from Audit Table
Hi, I have employee data from a time management system with clock in and out per day laid out in a table like the below; DATE USERID CLOCK 25/02/2020 1234 08:00:00 25/02/2020 1234 ...
- 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.
v-alq-msft
6 years agoCommunity Support
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.
pedanticpad
6 years agoHelper II
v-alq-msft that worked perfectly! Thanks so much for your help.