<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Pie Chart woes</title><link>https://community.appian.com/discussions/f/data/30900/pie-chart-woes</link><description>I&amp;#39;m currently trying to add a Pie chart into a reporting page. The report is doing a record type query and simply pulling back Id Items The issue is my Items are an array 
 The DB table looks like 
 1 Widget 
 2 Widget / Whatsit 
 3 Whatsit / Dohicky</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Pie Chart woes</title><link>https://community.appian.com/thread/123108?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 15:51:42 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a801bbc2-5436-4af7-8547-7de48cc46dd2</guid><dc:creator>pauls0010</dc:creator><description>&lt;p&gt;Too many comments n one...&lt;br /&gt;Agree the Db isn&amp;#39;t the best - this was an extension to another tech demo. And just fiddling with the &amp;#39;new&amp;#39;&amp;nbsp; records way of doing things as opposed to entity queries. Thanks for the response and the key was flatten. Just something i just couldn&amp;#39;t put my finger on.&lt;br /&gt;&lt;br /&gt;thanks all&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pie Chart woes</title><link>https://community.appian.com/thread/123107?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 15:48:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b8300534-0f1f-4c39-bf87-71658b3bce0a</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;...which was my very first comment - that the underlying model didn&amp;#39;t appear to be normalized and consequently you cannot leverage the power of the DB to aggregate it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pie Chart woes</title><link>https://community.appian.com/thread/123105?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 15:44:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f689fd44-bdd7-401a-9c17-bcdf9a47d84d</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;While that works as a tech demo, it will get you into performance trouble as soon as your data volume increases. Relational databases are really good in aggregating this kind of data, but to make use of it, you need to normalize your data model.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pie Chart woes</title><link>https://community.appian.com/thread/123104?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 15:31:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9632cefe-b7ce-4c0e-96e9-8cd66c203757</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;On the assumption that what you&amp;#39;ve provided so far is a precise representation of the data returned (e.g. the / symbol is the separator in your returned data) here&amp;#39;s how you might go about normalizing the data for use in your pie chart:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: {
    a!map(id: 1, value: &amp;quot;Widget&amp;quot;),
    a!map(id: 2, value: &amp;quot;Widget / Whatsit&amp;quot;),
    a!map(id: 3, value: &amp;quot;Whatsit / Dohicky&amp;quot;)
  },
  local!values: a!flatten(
    a!forEach(
      items: local!data.value,
      expression: fn!trim(fn!split(fv!item, &amp;quot;/&amp;quot;))
    )
  ),
  local!dedupedValues: fn!union(local!values, local!values),
  local!chartSeries: a!forEach(
    items: local!dedupedValues,
    expression: a!map(
      item: fv!item,
      count: fn!count(fn!wherecontains(fv!item, local!values))
    )
  ),
  a!pieChartField(
    series: a!forEach(
      items: local!chartSeries,
      expression: a!chartSeries(label: fv!item.item, data: fv!item.count)
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pie Chart woes</title><link>https://community.appian.com/thread/123102?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 15:02:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3a6e3a7e-2288-4f54-92c5-9bdcaf0ec099</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Interesting...a normalized model would have one table for the Order and another for the Order Items...&lt;/p&gt;
&lt;p&gt;On the assumption&amp;nbsp; you don&amp;#39;t have any influence over how the DB is modeled then you&amp;#39;ll need to manipulate your returned data to achieve a structure you can use in your pie chart.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pie Chart woes</title><link>https://community.appian.com/thread/123101?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 15:02:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c70c8cb3-2734-4e76-a5a2-50397192cae5</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Storing multiple values in a single field is a difficult design decision. Is that done by intention? How does your entity relationship model look like?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pie Chart woes</title><link>https://community.appian.com/thread/123100?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 14:57:32 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:51917a19-2350-4195-a326-b221fef66f42</guid><dc:creator>pauls0010</dc:creator><description>&lt;p&gt;Hi Stewart,&lt;br /&gt;The above was an example. the se case is that in another part of the site, a user can select multiple items of many different types.&amp;nbsp;&lt;br /&gt;Effectively each row in the DB is an order for multiple items. The list of items per order are stored in an array and written out to the db in a single column.&lt;/p&gt;
&lt;p&gt;I am trying to show in reporting how many of each type is ordered. It would not be very efficient to have a table with a column for each item. (which may change as we add / decrease the items)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pie Chart woes</title><link>https://community.appian.com/thread/123096?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 14:22:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e2a97672-38f9-41c7-8113-852edd8e53e9</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;My first instinct is that your underlying data model is incorrect. If the outcome you want to display a pie which has Widget (2), Whatsit (2) and Dohicky (1) then your database table should have two Widget rows, 2 Whatsit rows and 1 Dohicky row.&lt;/p&gt;
&lt;p&gt;If you have no control over the data model then you&amp;#39;ll need to manipulate/coerce the data that is returned so that it meets your needs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pie Chart woes</title><link>https://community.appian.com/thread/123087?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 12:53:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e7827a4c-ff27-4bda-8413-e7cab84ef55a</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Did you already check the documentation for some inspiration?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/23.4/Chart_Configuration_Using_Records.html"&gt;docs.appian.com/.../Chart_Configuration_Using_Records.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>