Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
mlarruda
Creator II
Creator II

How can I build a table with all column sums of my data?

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:

Col01Col02Col 03Col 04Col 05Col 06
123435
122210
163342
238157
112212
134522

I want to get this:

ColSum
Col017
Col0217
Col0322
Col0417
Col0516
Col0618

How can I do it?

Many thanks in advance.

1 Solution

Accepted Solutions
sunny_talwar

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)

View solution in original post

4 Replies
sunny_talwar

Why don't you use The Crosstable Load to transform your data and then just do Sum(Value) with Col as dimension

mlarruda
Creator II
Creator II
Author

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.

sunny_talwar

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)

mlarruda
Creator II
Creator II
Author

Worked! Thanks.