Like already mentioned it's an UI feature and not available within the script. But you could emulate the behaviour with exists(), like:
t: load ID, sum(Sales) * -exists(PDate, TDate) as Sales from Source group by ID;
but like all accesses on the system-fields you could it only apply by a single condition - not like by p() which could contain own conditions and/or be nested by more complex queries. Further you need to consider the load-order in the script because the related fields must be already loaded and appropriate named.
Of course with some adjustments you may also get more complicated scenarios to work and therefore the suggestion from Jordy is probably the more practically direction in regard to a general approach.