@ebarr , hopefully I’ve transposed the sample data correctly into the attached.
Java snippet - fill down with rules 20231115.knwf (10.7 KB)
The java snippet processes one row at a time from top to bottom of the table.
The variables defined in the “your custom variables” section are remembered from one row to the next, so we can use it to keep a copy of the output from the previous row.
Assuming no errors in my coding, or understanding, the if statements should represent the rules you gave. At the very end, you can see that it stores the current output “Date Sourced” value and the current campaign name.
At the beginning, it checks if the campaign name for the current row differs from the campaign name stored away. Note that java only has an “equals” method, but it is made “not equals” by the presence of the exclamation ! at the beginning of the condition, so not immediately obvious that this is a “not equals” test
So if the campaign name changes, it resets the “last date” to null.
If the DateSourced is missing (null), it checks if last date is null also. If it is, it uses the DateUnsourced, otherwise it uses the last date.
and… for the second time today , I’ll reference the following post which gives further insights into this feature of java snippet