title: Circumvent Valid Time State in AOT queries
body: <p>I have an AOT query in Dynamics AX 2012 which consists of the HcmWorker and HcmEmployment tables (among others). My problem is that when I create a report (not SSRS), or otherwise use this query, I only get the employees with a valid time state in HcmEmployment.</p>
  
  <p>I would like to get all employees that has a record in this table, even if they doesn't have a current employment - and only once. The optimal solution is to get the record from HcmEmployment for the current employment, if it exists, and otherwise the last record with a start date before "now". However, I can accept a solution where it joins with the last start date.</p>
  
  <p>I would prefer a solution where I do not need to add code every time I use it (i.e. solve it in the AOT query).</p>
  
  <p>I have tried setting the validTimeStateDateTimeRange property on the query from code, which resulted in duplicate lines if the employee has several employments. </p>
  
  <p>If I set the HcmEmployment datasource to ExistsJoin and firstOnly, then it works in a view, but not on reports (still duplicate records) :( Using this view on reports is not an option, because the users needs to be able to filter on DefaultDimension from HcmEmployment.</p>
  
  <p>How can I solve this problem?</p>