Tuesday, February 14, 2012
Column calculations in Crystal crosstabs
if first column then "colunm data" else
((this column - previous column)/Previous column )*100
How do I reference the columns in a crosstab?Just a *Bump* of sorts, I suppose.
I'm looking for a similar solution, though I'm not looking for a percentage variance. I'm referencing dollar amounts by category, broken out over two calendar years.... so far so good in the cross-tab. Totalling the fields is of no value, so I've suppressed the totals columns/rows. What I do need to be able to do is to subtract the 2007 data from the 2006 data to come up with the raw difference. For example, in the attached screen shot, I need to subtract the 2006 data from the 2007 data moving across.
How can I create a formula to accomplish this?
Any assistance from the experts is greatly appreciated. One of these days I'll get to take my swim fins off....
Column calculations
I have a select query that returns three integer fields from a table the
values range from 0 to 5. On each row I would like to calculate the average
value in the three fields however, the difficulty is that only the rows
where the value is greater than 0 should be included in the calculation.
To make this clearer please consider the following example:
Col1 Col2 Col2 Average Calculation
1 2 3 2 (Col1+Col2+Col3)/3
2 2 0 2 (Col1+Col2+Col3)/2
The first row should be divided by 3 because each of the three columns has a
value greater than 0, however the second row should be divided by 2 because
only two of the value are greater than 0.
Is this possible?
Also is is possible to pass the results of one calculation into another
calculation.
Thanks in advance,
SteveSELECT col1, col2, col3, (col1 + col2 + col3)/(case when col1 = 0 then
0 else 1 end + case when col2 = 0 then 0 else 1 end + case when col3 =
0 then 0 else 1 end)
FROM My_Table
-Tom.|||(col1+col2+col3) /
(SIGN(col1)+ SIGN(col2)+ SIGN(col3))
If they can be negative, use ABS(SIGN (X))|||Thanks Tom,
This worked fine.
"Thomas R. Hummel" <tom_hummel@.hotmail.com> wrote in message
news:1109973262.691311.81820@.o13g2000cwo.googlegro ups.com...
> SELECT col1, col2, col3, (col1 + col2 + col3)/(case when col1 = 0 then
> 0 else 1 end + case when col2 = 0 then 0 else 1 end + case when col3 =
> 0 then 0 else 1 end)
> FROM My_Table
> -Tom.