Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Sorting Issue: Difference in Dates in Days into Whole Number Field doesn't sort properly, why?

Posted on by

I had 2 date/Time fields, and wanted to know the duration of time between them.  The start date would (should) always be there and the end date was entered later.  If the end date is not there I use the current date.  I created a calculated whole number field which calculates the difference in dates.  Now I have a chart that is based on this value and I want to sort by this calculated field.  This is how it sorts it

  90 item
  221 item
  29 item
  197 item
  130 item
  129 item
  129 item
  165 item
  137 item
  102 item

Here is my Fetch XLM

<fetch mapping="logical" aggregate="true" top="10" >
  <entity name="job" >
    <attribute name="searchduration" alias="SearchDays" groupby="true" />
    <attribute name="jobtitle" alias="JobTitle" groupby="true" />
    <filter type="and" >
      <condition attribute="status" operator="eq" value="100000007" />
      <condition attribute="searchduration" operator="gt" value="0" />
    </filter>
    <order alias="SearchDays" descending="true" />
  </entity>
</fetch>


Am I missing something?

*This post is locked for comments

  • maustin Profile Picture
    maustin on at
    RE: Sorting Issue: Difference in Dates in Days into Whole Number Field doesn't sort properly, why?

    Whole number field

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Sorting Issue: Difference in Dates in Days into Whole Number Field doesn't sort properly, why?

    Hi

    Can you re-check the given field is numeric or text? I think it consider as numeric

  • Suggested answer
    Suresh Sorde Profile Picture
    Suresh Sorde 1,075 on at
    RE: Sorting Issue: Difference in Dates in Days into Whole Number Field doesn't sort properly, why?

    Hi

    Check this

    Hope this helps

    Thanks

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Sorting Issue: Difference in Dates in Days into Whole Number Field doesn't sort properly, why?

    It looks like your field is text field. Please recheck the field.

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Sorting Issue: Difference in Dates in Days into Whole Number Field doesn't sort properly, why?

    Hi,

    See: crmchartguy.wordpress.com/.../sort-chart

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans