|
Replies:
9
-
Pages:
1
-
Last Post:
Feb 21, 2008 4:54 AM
Last Post By: Remc0
|
|
|
Posts:
509
Registered:
01/17/07
|
|
|
|
don't show 0 when the sum of a group is null
Posted:
Feb 4, 2008 3:32 AM
|
|
|
Hello all,
When the following in a group:
<?sum(current-group()/_saw_8_ http://.!=’’)?>
It returns a 0 when all values are null.
But 0 means smaller then 0,5 and null means it is not there
Now my question is: how can I sum the values and make a different between 0 and null?
Best regards,
Remco
|
|
|
Posts:
468
Registered:
05/04/07
|
|
|
|
Re: don't show 0 when the sum of a group is null
Posted:
Feb 4, 2008 2:14 PM
in response to: Remc0
|
|
|
|
put the value in a variable do and if statement. if sum_value != "0" and sum_value != ""
|
|
|
Posts:
509
Registered:
01/17/07
|
|
|
|
Re: don't show 0 when the sum of a group is null
Posted:
Feb 5, 2008 10:12 PM
in response to: Ike Wiggins
|
|
|
|
Ok, and how can I do that?
(sorry for the question, but as we say in holland: I don't have eaten any chees of variables)
|
|
|
Posts:
245
Registered:
12/19/07
|
|
|
|
Re: don't show 0 when the sum of a group is null
Posted:
Feb 7, 2008 12:38 AM
in response to: Remc0
|
|
|
|
To declare a variable named 'xxx' use the following syntax
<?xdoxslt:set_variable($_XDOCTX, 'xxx', 0)?>
This will declare the variable 'xxx' and assign it a value 0
To change the value of the variable use
<?xdoxslt:set_variable($_XDOCTX, 'xxx', 1)?>
To retrieve the value to the variable use
<?xdoxslt:get_variable($_XDOCTX, 'xxx') ?>
The value of the variable can be compared with some value as follows
<?if: xdoxslt:get_variable($_XDOCTX, 'xxx') =0?>
|
|
|
Posts:
2,263
Registered:
01/10/01
|
|
|
|
Re: don't show 0 when the sum of a group is null
Posted:
Feb 7, 2008 11:06 AM
in response to: Remc0
|
|
|
|
Hey Remco
How about something like this
<?xdoxslt:ifelse(sum(AMOUNT)=0,'',sum(AMOUNT))?>
So if the sum = 0 ie all null then dont show anything otherwise sow the amount. The only problem will be if you have '0' values
Tim
|
|
|
Posts:
348
Registered:
05/02/06
|
|
|
|
Re: don't show 0 when the sum of a group is null
Posted:
Feb 7, 2008 4:42 PM
in response to: Tim Dexter
|
|
|
|
Hi Remco,
Are you trying to summate a list of values that could contain nulls?
If so then using <?sum(ELEMENTS)?> will not work and probably give you NaN errors, instead, try using <?xslt:sum(ELEMENTS)?>, this should ignore null elements and return the correct result.
I hope this helps.
Regards,
Cj
|
|
|
Posts:
509
Registered:
01/17/07
|
|
|
|
Re: don't show 0 when the sum of a group is null
Posted:
Feb 7, 2008 11:17 PM
in response to: Chris Brown
|
|
|
|
Hi Chris and Brown,
I am trying to summate a list of values indeed, but the list is in a group.
So if I want to summate the list I must use: <?sum(current-group()/ELEMENT)?>.
But both of your replies will help me out.
@Tim: Sometimes the list is as following: null, null, null, 0 --> if that happens I want to see a 0 if the list is null, null, null, null then I want to see nothing
@Chris: I don't get any NaN errors when I use <?sum(current-group()/ELEMENT)?>
But when I am using <?xslt:sum(current-group()/ELEMENT)?> I will get a error. Only when I choose tools -> validate it says there are no errors, but when I request a preview it returns an error without any details.
Best regards,
Remco
|
|
|
Posts:
9
Registered:
05/11/07
|
|
|
|
Re: don't show 0 when the sum of a group is null
Posted:
Feb 8, 2008 7:45 AM
in response to: Remc0
|
|
|
|
Could you count the number of elements, compare it to the count of the number of elements that are null, if they are the same then output null otherwise output the sum.
Something like ( haven't tested it...)
<?xdoxslt:ifelse(count(AMOUNT)=count(AMOUNT),'',sum(AMOUNT))?>
hope it helps
Graham
|
|
|
Posts:
509
Registered:
01/17/07
|
|
|
|
Re: don't show 0 when the sum of a group is null
Posted:
Feb 11, 2008 6:07 AM
in response to: GrahamHewett
|
|
|
|
Thanks! It looks like this is what I want!
Best regards,
Remc0
|
|
|
Posts:
509
Registered:
01/17/07
|
|
|
|
Re: don't show 0 when the sum of a group is null
Posted:
Feb 21, 2008 4:54 AM
in response to: GrahamHewett
|
|
|
|
Thanks again Graham,
Untill today we hadn't any time to test what you said.. but to count the elements was a good idea! This is the exact syntax we are using now:
<?xdoxslt:ifelse(count(current-group()/_saw_2_)=0,'',sum(current-group()/_saw_2_))?>
And this works fine!
|
|
|
|
Legend
|
|
Guru : 2500
- 1000000
pts
|
|
Expert : 1000
- 2499
pts
|
|
Pro : 500
- 999
pts
|
|
Journeyman : 200
- 499
pts
|
|
Newbie : 0
- 199
pts
|
|
Oracle ACE Director
|
|
Oracle ACE Member
|
|
Oracle Employee ACE
|
|
Helpful Answer
(5 pts)
|
|
Correct Answer
(10 pts)
|
|