Using Report Builder 3.0 to create a Chart with XML Data

In my previous article on Report Builder 3.0, we discussed how report parts can be published. In this article, we will create a chart with XML data without connecting to any database.

1. Start Report Builder 3.0 > Select Report > Chart wizard and click Create

2. Select ‘Create a dataset’ and click Next > from Data source connection click New tab

3. Change the selection type to XML

clip_image002
and click Ok

4. Paste following query in the query designer and click Next

<Query>
ElementPath>Root /Rating {@GlobalRating (Integer)} /NM {@Name} </ElementPath>
<
XmlData>
<
Root>
<
Rating GlobalRating="300">
<
NM Name="Priti Zinta" />
</
Rating>
<
Rating GlobalRating="500">
<
NM Name="Aishwarya Rai" />
</
Rating>
<
Rating GlobalRating="650">
<
NM Name="Madhuri Dixit" />
</
Rating>
<
Rating GlobalRating="750">
<
NM Name="Katrina Kaif" />
</
Rating>
<
Rating GlobalRating="450">
<
NM Name="Priyanka Chopra" />
</
Rating>
</
Root>
</
XmlData>
</
Query>

5. If you execute the query, you will get the following results:

clip_image004

6. Select Pie chart > double click on ‘GlobalRating’ which will automatically go to values. Drag and Drop name in categories area and click Next. Select ‘Mahogany’ as the style and click Finish.

7. The chart looks as follows after increasing the size, when you run the report.

clip_image006

8. Let us give chart titles, labels and other details to the chart. Enter chart title as “Global Percent for film stars”. Right click on the chart area and set data labels on. Again select the data labels and go to the properties. We will display film star name along with the percentage for rating. Enter the following expression in property for label :

= "#LEGENDTEXT" & vbcrlf & " #PERCENT{P0}"

9. The result is as follows:

clip_image008

You will also observe that the tooltip shows the sum of global rating, if pointed to any percent.

3 comments:

  1. Can XML be read as a stream and passed to Report Builder?

    ReplyDelete
  2. Thanks for the good article. Just in case anyone copy/pastes your query verbatim as a test, it seems to be missing the opening bracket ("<") on the ElementPath

    ReplyDelete