Order (or Sort) your charts

Update 4/6/2017: Post updated to apply to all versions of Dynamics CRM from CRM 2011 to Dynamics 365.

The Order of which a series is displayed can be a little tricky to work with. If no order is defined in the chart, the chart will display your data according to the sort order defined in the View that you are using. So excluding the order clause from the chart can give you a more dynamic way of adjusting your charts, as you won’t need to do XML customizations. Relying on the view also limits your sorting options to name fields or dates. I.e. you cannot use the View settings to order on aggregated fields.

However, it is often needed to specify one or more order clauses to make sure your data is presented properly.

To specify how data is ordered, or sorted, we utilize the Order clause in the fetchcollection in the XML.

In this example, I have added two order clauses to a case chart.
Dynamics 365, Dynamics CRM chart XML order clause, sorting charts
The first line is the primary sort order and the following line is the secondary sort order. That way you can control the sort orders by adding the order clauses in the correct order. That was too many “orders” for one sentence.


Hope you found the tip useful. As always please sign up for my newsletter and follow me on Twitter.

12 thoughts on “Order (or Sort) your charts

  1. Is it possible to sort a chart by the x axis? For example if my a axis values are 1-10 I want them to appear in that order. At the moment group 3 has a higher count than those records in group 1 so 3 appears first.


  2. I have an issue with chart sorting. Here’s my fetch:

    The industrycode is actually a picklist, and it does not sort correctly. In fact, it doesn’t seem to sort logically at all. The results are neither alphabetical nor sorted by count. It makes no difference whether or not I leave the “order” clause in the fetch statement.

    I see this same behavior for any chart using a picklist as the series. Charts using other types of values sort correctly.

    Have you seen this before?

  3. I’m trying to sort an Opportunity Product view. I am able to use the view sort to get my first sort correct. The problem is coming from an Opportunity column I added to the view that is for the “stepname” or Pipeline Phase on the Opportunity entity. I see in your blog that you cannot sort on related entities, is this still true? My problem is our pipeline chart is sorted by fiscal period on the bottom axis, and I have stacked columns to show the pipeline phase by color, but one week the “90%” stage will be blue, then next week it’s yellow, or another color. Frustrating and it’s hard to visually read the chart without using the legend. Any help would be awesome. Thanks!

    • That is how I sort my first level. Sorting the 2nd level is impossible without editing XML because my 2nd criteria is from another entity. Thanks for the suggestion though.

  4. Struggling to figure out how to sort by fiscal period in my grouped goals (by custom region field) chart… see below: Keeps sorting by the following – Q2, Q4, Q3 :/. Any help?

    Regional Quarterly Progress (Fiscal Year)


  5. Is there a way to order by a “calculated field”?
    I have 2 currency fields on an Opportunity that are being added into a calculated field. When I create a chart that
    – groups by customer
    – summarizes the calculated
    I cannot sort by the calculated field nor ad a top 10 filter. Can you help me with this?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s