title: Sorting on a calculated field with X++
body: <p>I am a long time developer in MS Access but Now I need to develop in Microsoft Dynamics AX 2009.</p>
  
  <p>I have a report that uses a method on the body of a report that calculates an "exp book date". Now I am being asked to sort on this field.
  I am guessing I need to move the method to the query, in order to make the field able to be sorted.
  But when I copy the method to the Method level of the query, it say that the field does not exist. Which it doesn't. How do i get the feild to be visiable?</p>
  
  <pre><code>display utcDatetime Test()
  {
      real            AddDays;
      utcDatetime     CDate;
      ;
  
      AddDays = smmQuotationPrognosisGroup::find(smmOpportunityTable_1.PrognosisId, false).PrognosisDays;
  
      CDate = smmOpportunityTable::find(smmOpportunityTable_1.OpportunityId, false).createdDateTime;
  
      return DateTimeUtil::addDays(CDate, AddDays);
  
  }
  </code></pre>