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.

Notes:

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

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

    Thanks

  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!

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

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

  5. 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)
    goal

    false

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

  7. i want to create a stacked barchart for monthy pipeline and comitment. The problem is that i have in one colum values that are either empty or “yes”. However i change the sorting in the view or in the diagrams xlm, i cant get the empty ones to be on top of the “yes” in the chart. do you have any idea?

    love your page by the way! helped me out a lot

  8. i want to create a stacked barchart for monthy pipeline and comitment. The problem is that i have in one colum values that are either empty or “yes”. However i change the sorting in the view or in the diagrams xlm, i cant get the empty ones to be on top of the “yes” in the chart. do you have any idea?

    love your page by the way! helped me out a lot

  9. Is it possible to order a chart based on a field of the underlying view that is not displayed in the chart? Example:
    I have a chart that plots Overdue invoices (sum) as a series and Customer (Account) and Invoice Owner as category. Gives me a nice chart that tells me who is overdue, by how much and who on our side is responsible for following up. The problem is that the order seems to be completely random, even though the view is ordered by due date.
    How do I order my chart by due date?

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 )

Connecting to %s