• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to sum from 2 fields?

 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my xml



I want to sum the total sale prices, in this case it will be $14 because the 1st one does not sell any ticket

The simplest way I think of is to multiple price with sold for each ticket and then sum it all up.

I group by <ticket> and below is my code but I got 0

<?sum(current-group()/sold * current-group()/price)?>

Do you know why? If you have a simpler approach, please let me know

Thanks
 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing, the <sold></sold> tag will only have 2 values (1 or 0)
 
g tsuji
Ranch Hand
Posts: 669
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<?sum(current-group()/sold * current-group()/price)?>

What is it? Where do you learn this syntax, remotely like a processing-instruction but not being one?

I group by <ticket>

Suppose you mean what you say and thereby you mean you're working with xslt 2.0 as well.
One more thing, the <sold></sold> tag will only have 2 values (1 or 0)

If you do thing right, it does not generically matter.

Here is how at the current-group() (xslt 2.0) of what you said you have grouped.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic