Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
My data has several rows and some dozens of columns (let's call them COL01, COL02, COL03 etc.) and I want to have a summary of all column sums, like in example below.
From this table:
Col01 | Col02 | Col 03 | Col 04 | Col 05 | Col 06 |
---|---|---|---|---|---|
1 | 2 | 3 | 4 | 3 | 5 |
1 | 2 | 2 | 2 | 1 | 0 |
1 | 6 | 3 | 3 | 4 | 2 |
2 | 3 | 8 | 1 | 5 | 7 |
1 | 1 | 2 | 2 | 1 | 2 |
1 | 3 | 4 | 5 | 2 | 2 |
I want to get this:
Col | Sum |
---|---|
Col01 | 7 |
Col02 | 17 |
Col03 | 22 |
Col04 | 17 |
Col05 | 16 |
Col06 | 18 |
How can I do it?
Many thanks in advance.
Try this script
Table:
CrossTable (Col, Value)
LOAD 1 as Dummy,
*;
LOAD * INLINE [
Col 01, Col 02, Col 03, Col 04, Col 05, Col 06
1, 2, 3, 4, 3, 5
1, 2, 2, 2, 1, 0
1, 6, 3, 3, 4, 2
2, 3, 8, 1, 5, 7
1, 1, 2, 2, 1, 2
1, 3, 4, 5, 2, 2
];
and then
Dimension
Col
Expression
Sum(Value)
Why don't you use The Crosstable Load to transform your data and then just do Sum(Value) with Col as dimension
I managed to do it by creating a graphic table with expressions "SUM(COL01)", "SUM(COL02)", "SUM(COL03)" etc. but, since there are many columns, I wished to do it through a shorter way.
Try this script
Table:
CrossTable (Col, Value)
LOAD 1 as Dummy,
*;
LOAD * INLINE [
Col 01, Col 02, Col 03, Col 04, Col 05, Col 06
1, 2, 3, 4, 3, 5
1, 2, 2, 2, 1, 0
1, 6, 3, 3, 4, 2
2, 3, 8, 1, 5, 7
1, 1, 2, 2, 1, 2
1, 3, 4, 5, 2, 2
];
and then
Dimension
Col
Expression
Sum(Value)
Worked! Thanks.