Add Percentage Labels to a 100% Stacked Bar chart in MS Dynamics CRM

The 100% stacked bar chart is great to display the relative amounts within a series.

However, for some reason the 100% stacked bar chart comes without labels to indicate what the percentage is for each group. You can eyeball it, but that’s not very accurate.

Original StackedBar100 chart

A 100% stacked bar chart made in the MS Dynamics CRM chart editor. No labels.

It is a little tricky to get to the accurate result, so I will go through the process of getting there.

The obvious thing to try first, is to export the chart xml and add IsValueShownAsLabel=”True” to the series.

        <Series ChartType="StackedBar100" IsValueShownAsLabel="True" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PointWidth=0.75, MaxPixelPointWidth=40">
          <SmartLabelStyle Enabled="True" />
        </Series>

 

IsvalueShownAsLabel True on a StackedBar100 chart

IsValueShownAsLabel=”True” added. Labels are the sum of the group.

This gives us the sum of each individual phase. This could be useful in its own right, but I really want the percentage on the label.

The next obvious thing to try, is to put in Label=”#PERCENT” and set IsValueShownAsLabel=”False”. Why not? It works great for pie charts.

        <Series ChartType="StackedBar100" IsValueShownAsLabel="False" Label="#PERCENT" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PointWidth=0.75, MaxPixelPointWidth=40">
          <SmartLabelStyle Enabled="True" />
        </Series>

 

Keyword PERCENT on StackedBar100 chart

Keyword Label=”#PERCENT” added. The percentages run across the bars rather than within a single bar.

Now we get some great looking percentages, but the values add up to 100 on the second series. Not across like we would expect.

The magic combo to add to the series xml for percentage labels on a 100% stacked bar chart in MS Dynamics CRM is:

IsValueShownAsLabel=”True” LabelFormat=”#.00′ %'”

        <Series ChartType="StackedBar100" IsValueShownAsLabel="True" LabelFormat="#.00' %'" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PointWidth=0.75, MaxPixelPointWidth=40">
          <SmartLabelStyle Enabled="True" />
        </Series>

 

StackedBar100 chart with correct percentages as labels in Microsoft Dynamics CRM charts.

With IsValueShownAsLabel=”True” and LabelFormat added, the percentages on the labels now display as intended.

Finally we have proper percentages across on the bar chart as we would expect.

 

A couple of other optimizations for a percentage bar chart.

LabelFormat=”#.00 ‘%'” in the series to show the percentage sign and always have 2 decimals.

Format=”0’%'” on the Y-axis to remove decimals and add percentage sign.

More on where and how to add Format and LabelFormat in MS Dynamics CRM charts here.

Thank you for reading. Please sign up for the newsletter to stay up to date on new blog posts and follow me on Twitter

Advertisements

, ,

  1. #1 by sharjeelbutt on September 18, 2015 - 11:42 am

    I have a chart that displays the Est Revenue (in blue) and Actual revenue (in orange) by month for the entire year. How do I display only the Actual revenue as a % of the Est. Rev?

  2. #2 by Seth on November 4, 2015 - 8:21 am

    I have a similar question. I’m trying to create a chart showing the % year over year (or month over month) growth $.

  3. #3 by Sammie on September 1, 2016 - 7:53 am

    I tried adding IsValueShownAsLabel=”True” in the Chart Series, but it did not work in crm 2016 online? Any suggestions??

    • #4 by CRM Chart Guy on September 1, 2016 - 9:47 am

      I have not had any issues with that property in CRM2016.

      • #5 by Sammie on September 1, 2016 - 11:28 am

        Here is the error log:
        Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: PresentationDescription is invalid and cannot be loaded. Message: Cannot deserialize property. Unknown property name ‘IsValueShowAsLabel’ in object ” System.Web.UI.DataVisualization.Charting.SeriesDetail:

        -2147164138

        0
        PresentationDescription is invalid and cannot be loaded. Message: Cannot deserialize property. Unknown property name ‘IsValueShowAsLabel’ in object ” System.Web.UI.DataVisualization.Charting.Series

        PresentationDescription is invalid and cannot be loaded. Message: Cannot deserialize property. Unknown property name ‘IsValueShowAsLabel’ in object ” System.Web.UI.DataVisualization.Charting.Series
        2016-09-01T14:07:11.0706653Z

      • #6 by CRM Chart Guy on September 1, 2016 - 12:55 pm

        It’s just a typo. There’s an “n” missing.

      • #7 by Sammie on September 1, 2016 - 1:05 pm

        I don’t get it.. the property is missing “n”..?

      • #8 by CRM Chart Guy on September 1, 2016 - 1:10 pm

        IsValueShowAsLabel is in your error message
        IsValueShownAsLabel is how the property should look

        Generally, the “Unknown property name” error messages are usually always typos.

      • #9 by Sammie on September 1, 2016 - 1:20 pm

        You are awesome.. Thank you for helping me fix 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 )

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: