Order (or Sort) your charts

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.
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.



, , , ,

  1. #1 by Jon on August 7, 2014 - 4:18 am

    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. #2 by REH on February 9, 2015 - 3:59 pm

    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. #3 by Tim Dailey on February 17, 2016 - 6:24 pm

    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!

    • #4 by Jake Furlong on April 25, 2016 - 7:40 am

      Sort the column you want on the view. That will translate over to the chart.

  4. #5 by Jake Furlong on April 25, 2016 - 7:39 am

    You have to configure the sorting on the column on your choice within the view the chart is based on.

  5. #6 by Jake Furlong on April 25, 2016 - 7:41 am

    • #7 by Tim on April 27, 2016 - 1:20 pm

      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.

  6. #8 by Jeff on October 24, 2016 - 10:45 am

    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)


  1. Specify Exact Colors for Each Priority in the Microsoft Dynamics CRM 2011 Case Chart | crm chart guy
  2. Charting on Activity Parties in MS Dynamics CRM | crm chart guy

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: