Forum Discussion
Something more practical than an IF Statement
- 5 years ago
Hi J_o_n_a_s ,
If different employees change department on different dates, I think it is necessary to compare date for each employee but you can try to optimize the formula, for example, using switch() function, using variables, like this:
Column = VAR date1 = DATE ( 2020, 12, 31 ) VAR date2 = DATE ( 2020, 5, 8 ) VAR new = [Employee] & 2 RETURN SWITCH ( [Employee], "Jonas", IF ( [Date] > date1, new, [Employee] ), "A", IF ( [Date] > date2, new & 2, [Employee] ) )Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi J_o_n_a_s ,
You need not to write if statements for each employees, just distinguish it by [Date], create column like this:
Column =
IF ( 'Table'[Date] > DATE ( 2020, 12, 31 ), [Employee] & "2", [Employee] )
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- J_o_n_a_s5 years ago
Helper I
But what if different employees change department on different dates?
- v-yingjl5 years ago
Community Support
Hi J_o_n_a_s ,
If different employees change department on different dates, I think it is necessary to compare date for each employee but you can try to optimize the formula, for example, using switch() function, using variables, like this:
Column = VAR date1 = DATE ( 2020, 12, 31 ) VAR date2 = DATE ( 2020, 5, 8 ) VAR new = [Employee] & 2 RETURN SWITCH ( [Employee], "Jonas", IF ( [Date] > date1, new, [Employee] ), "A", IF ( [Date] > date2, new & 2, [Employee] ) )Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.