?
Solved

XSLT SUM  IF example

Posted on 2011-05-02
6
Medium Priority
?
1,587 Views
Last Modified: 2013-11-11
Hi,

Thank you for taking the time to look at my question.

Essentially I have the following XSL:
<clientdemo><transaction><account>16</account><tr_to_agency>-2808.6</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20090202</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091128</tr_listed_date></transaction>
<transaction><account>1</account><tr_to_agency>750</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20100505</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091128</tr_listed_date></transaction>
<transaction><account>1</account><tr_to_agency>0</tr_to_agency><tr_to_client>250</tr_to_client><tr_payment_date>20100527</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091128</tr_listed_date></transaction>
<transaction><account>1</account><tr_to_agency>1200</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20100712</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091128</tr_listed_date></transaction>
<transaction><account>1</account><tr_to_agency>100</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20100909</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091128</tr_listed_date></transaction>
<transaction><account>16</account><tr_to_agency>-35.8</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20100529</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20100703</tr_listed_date></transaction>
<transaction><account>16</account><tr_to_agency>-1000</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20090330</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091230</tr_listed_date></transaction>
</clientdemo>

and what I want to do is if account=16 and trpaymentdate > 20091231 and trpaymentdate is <=20100131 sum of all tr_toagency and sum of all tr_to_client and then sum these two figures together.

Could someone please help with how the XSLT sheet would look?  Once I see how you go about that I can then fill in what I need to.

Many thank you's in advance.
0
Comment
Question by:mavmanau
  • 4
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
zc2 earned 2000 total points
ID: 35509677
Please test the following template, I guess it's that you need
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<xsl:variable name="scope" select="/clientdemo/transaction[account = 16 and tr_payment_date &gt; 20091231 and tr_payment_date &lt;= 20100131]"/>
		<xsl:value-of select="sum($scope/tr_to_agency) + sum($scope/tr_to_client)"/>
	</xsl:template>
</xsl:stylesheet>

Open in new window

0
 

Author Comment

by:mavmanau
ID: 35509732
many thank you's I think I can work out most of what I need from there except for one more quick question that I forgot to include as part of original.  Say I am feeding in a value for clientrowid.  When the page first loads, this is of course blank, but if the user clicks on a row above this particular section and selects a particular clientrowid that is then fed into the XSLT page, how would I then make it choose to only do the ones with that particular ClientROWid...say for example it is 2??
0
 

Author Comment

by:mavmanau
ID: 35509733
that works perfect though, the first part you have given me.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Closing Comment

by:mavmanau
ID: 35509934
Thank you!! very appreciative, very quickly done too!!
0
 
LVL 19

Expert Comment

by:zc2
ID: 35513446
You welcome. So, did you figure out how to feed an input id value?
0
 

Author Comment

by:mavmanau
ID: 35714292
i think so...I am trying at the moment!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question