This transformation can use arbitrary logic, but it should be deterministic so that you can run it again and derive the same application state from the event log.
A projection of the event log must be deterministic. Meaning that, given the same log, at the exact position, should produce the same projection every time.