[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Grouping, Sorting on Aggegrated sum of the groupings,

Subject: Grouping, Sorting on Aggegrated sum of the groupings, for Top XX Groupings
From: "Darin" <darind@xxxxxxxxx>
Date: Mon, 13 Jun 2005 16:14:39 -0400
running sum
I am using MSXML 4.0 running on an IIS 5.0 server running classic ASP.

I'm trying to transform the xml below grouped by the Id attribute, and sort
(descending) on the aggregated sum(Value).  I'm also trying to limit the
amount of groupings to 6, where the first 5 groupings are the highest
aggregated sum values, and the 6th grouping is an aggregation of the
remaining groups.

Here is an example of the XML:

    <y Id="1" Name="Label" Value="2151"/>
    <y Id="2" Name="Label1" Value="2760"/>
    <y Id="2" Name="Label1" Value="50"/>
    <y Id="3" Name="Label2" Value="99"/>
    <y Id="4" Name="Label3" Value="9"/>
    <y Id="4" Name="Label3" Value="55"/>
    <y Id="5" Name="Label4" Value="56"/>
    <y Id="13" Name="Label5" Value="118"/>
    <y Id="14" Name="Label6" Value="193"/>
    <y Id="17" Name="Label7" Value="54"/>
    <y Id="23" Name="Label8" Value="76"/>
    <y Id="23" Name="Label8" Value="76"/>
    <y Id="23" Name="Label8" Value="76"/>
    <y Id="25" Name="Label9" Value="100"/>

I would like the xml to look like:

<!-- Summation of the Top 5 entries aggregated sum (Desc) -->
    <y Id="2" Name="Label1" Value="2810"/>
    <y Id="1" Name="Label" Value="2151"/>
    <y Id="23" Name="Label8" Value="228"/>
    <y Id="14" Name="Label6" Value="193"/>
    <y Id="13" Name="Label5" Value="118"/>

<!-- Summation of the remaining entries -->
    <y Id="" Name="Other" Value="373"/>

<!-- <y Id="3" Name="Label2" Value="99"/>
    <y Id="4" Name="Label3" Value="64"/>
    <y Id="5" Name="Label4" Value="56"/>
    <y Id="17" Name="Label7" Value="54"/>
    <y Id="25" Name="Label9" Value="100"/> -->

I have tried to use Keys and the XPath position function, but with no

Thanks in an advance for any help!


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.