Which, I realize, is not the greatest title in the world, but I'm not sure what else to call this.
So, the list data looks a little like this:
More or less. Basically, a set of products are lumped into a product group and clients are either using them or not. I have about 80+ products put into 20 or so product groups for something near 40+ clients.
What I'm trying to do is build an XSLT that shows the percent penetrated (I know, I know...) for the product group.
The output would look something like this, as based on the sample data included above:
Group 1: 33.33% penetrated
This number is defined by:
- First, per client, within the product group, counting how many products are "in use".
- Then, dividing that count by the total number of products, per client, to get a percentage.
- If that percentage is over 50 (meaning, if the client is using more than half of the products in the group), count that client as "using" the product group.
- Take that count and divide it by the total number of unique clients within a product group, to derive a percentage "using" the product group.
I've been able to pull a percentage for each individual product pretty easily (@Title is the Product):
<xsl:variable name="rowYes" select="count($Rows[@Title = current()/@Title and @InUse = 'Yes'])"/>
<xsl:variable name="allRows" select="count($Rows[@Title = current()/@Title])"/>
<xsl:variable name="percPen" select="$rowYes div $allRows"/>
Then, in the table, I just call that $percPen variable for each @Title, formatting it as a percentage.
Taking it out a level is doing my head in. To summarize:
- Count, per unique client, per unique product group, InUse = y.
- Divide by total number of rows, per unique client, per unique product group.
- Test result. Count all results > .5 per unique client, per unique product group.
- Divide by total number of results to derive percentage.
It is beyond my puny brain. Help?