XSL Dashboard

Previously I had some issues trying to display SharePoint List data as rollups using a DataView Web Part (DVWP).  The problem I had is in remembering how to do a count of a query for every row that satisfies a condition, like a status or category.

The trick is creating variables and then calling the variables later, which really helps in creating percentages.

These 2 variables are default with every DVWP:
  <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
  <xsl:variable name="dvt_RowCount" select="count($Rows)"/>
You can call the total number of items in a list like this:
  <xsl:value-of select="$dvt_RowCount"/>

Here is an example of a way to show the number of items in a list split up by status.  Status is a drop-down choice column with 3 values: (Input, In Progress, Complete)

<xsl:variable name="InputCount" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Status)='Input'])" />
<xsl:variable name="InProgressCount" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Status)='In Progress'])" />
<xsl:variable name="CompleteCount" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Status)='Complete'])" />

Later call these variables in your display <table> or <div> using CSS for styling and layout.  To show percentages divide the dvt_RowCount variable by the individual counts.  To show bars that adjust their height or width (vertical or horizontal) by the total then set the width of <div> tags by the variables as percentages.


Popular posts from this blog

SharePoint Designer 2013 Approval Workflow with Comments

Change SharePoint server hostname and Web Application Names

The Timer Service Failed to Recycle