Hello Community,
I have the below data and I am using a formula currently to trim the '-' if the Code column is empty and populate it similar to this value - D20240130 using the below formula.
IF !IsEmpty([Date]) AND IsEmpty([Code]) THEN "D" + Replace([Date], '-', '') ELSE
[Code]
ENDIF
Now, I am trying to add another condition which removes the value '20' from the left. When I add a TrimLeft to the above formula, it is removing more characters than required.
Table 1
Code | Date |
ABC123 | 2022-02-21 |
2024-01-30 | |
DEF123 | 2023-11-30 |
2020-03-15 | |
2020-11-27 | |
GHI123 | 2025-11-10 |
2026-05-20 |
Table 2
Code | Date |
ABC123 | 2022-02-21 |
D240130 | 2024-01-30 |
DEF123 | 2023-11-30 |
D200315 | 2020-03-15 |
D201127 | 2020-11-27 |
GHI123 | 2025-11-10 |
D260520 | 2026-05-20 |
Can anyone suggest on how to achieve this?
Solved! Go to Solution.
Hi @ssripat3 ,
Try this:
IF !IsEmpty([Date]) AND IsEmpty([Code]) THEN "D" + REGEX_Replace( Replace([Date], '-', ''), "^20","") ELSE
[Code]
ENDIF
I added a regexreplace that will remove the "20" from the front of the text string :)