Tuesday, January 27, 2015

MS CRM Chart - Axis labels sorting by month



In above chart, all month are not shown in correct order.
To correct the order / sort those labels, we need to export chart XML.
In Chart XML, need to look for FetchCollection
<fetchcollection>
  <fetch mapping="logical" aggregate="true">
    <entity name="new_test">
      <attribute groupby="true" alias="_CRMAutoGen_groupby_column_Num_0" dategrouping="month" name="new_date" />
      <attribute alias="_CRMAutoGen_aggregate_column_Num_0" name="new_phone" aggregate="count" />
    </entity>
  </fetch>
</fetchcollection>

Update this fetchXML with 


<fetchcollection>
  <fetch mapping="logical" aggregate="true">
    <entity name="new_test">
      <attribute groupby="true" alias="_CRMAutoGen_groupby_column_Num_0" dategrouping="month" name="new_date" />
      <attribute alias="_CRMAutoGen_aggregate_column_Num_0" name="new_phone" aggregate="count" />
      <order alias="_CRMAutoGen_groupby_column_Num_0" descending="false"/>
    </entity>
  </fetch>
</fetchcollection>

Notice that I used alias of my Date attribute for order. 

Save your XML and reimport to CRM, publish and done..
Now your chart will be look like 


2 comments:

  1. Thanks for the post! What if we have a horizontal bar chart? My vertical column graph is fine, but the horizontal is still out of order.

    ReplyDelete