@aworker I’m not sure I’m more skilled than you with the Column Expressions. I’m sure you do well with it But if you insist.
@MrKatze just to clarify your rules: I think by “digit” you mean character, and that’s based on your screenshot and also “.” is not a digit. So, I’ve created something that will take the first 6 or 12 characters not digits.
Workflow looks like this:
Input data:
Note: I’m not sure why your input file is encoded in UTF-16. It’s easily fixed by enforcing the encoding.
Results:
This looks the same as your expected results.
These are the rules that were implemented in the Column Expression:
if(isMissing(column("PSP-Element")) && isMissing(column("Kostenstelle")) && substr(column("Text"), 1, 1) == ".") {
substr(column("Text"), 0, 6)
} else if(isMissing(column("PSP-Element"))) {
column("Kostenstelle")
} else if(substr(column("PSP-Element"), 0, 1) == "L") {
substr(column("PSP-Element"), 0, 12)
} else {
substr(column("PSP-Element"), 0, 6)
}
They have to be implemented in that order so that they do not interfere with each other. Coincidently, they’re exactly in the reverse order of how the rules were given
Here’s the workflow: Set values based on existing values.knwf (8.7 KB)