Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
poluvidyasagar
Creator II
Creator II

Sum up values based on dimension during load???

Hi,

I am trying to achieve the following. Can someone explain how do i load the following with the result table shown below:

  

Dataset1:
PNDay1 Day2:Day3:
1234345
2345101210
3456987
5678688
9876568

  

Dataset2:
PNDay1 Day2:Day3:
9981345
6671101210
5674987
1234101010
2345202020

  

Result:
PNDay1 Day2:Day3:
1234131415
2345303230
3456987
5678688
9876568
9981345
6671101210
5674987

I tried to use the concatenate/Join, but it does give me the parts repeated twice in both tables.

Can someone help?

Thanks,
Vidya

1 Solution

Accepted Solutions
vamsee
Specialist
Specialist

Try

Dataset1:
LOAD * INLINE [
PN, Day1, Day2, Day3
1234, 3, 4, 5
2345, 10, 12, 10
3456, 9, 8, 7
5678, 6, 8, 8
9876, 5, 6, 8
]
;
Concatenate
Dataset2:
LOAD * INLINE
PN, Day1, Day2, Day3
9981, 3, 4, 5
6671, 10, 12, 10
5674, 9, 8, 7
1234, 10, 10, 10
2345, 20, 20, 20

]
;
Result:
NoConcatenate
LOAD
PN,
SUM(Day1) as Day1,
SUM(Day2) as Day2,
SUM(Day3) as Day3
Resident Dataset1
Group by PN;
DROP Table Dataset1;

View solution in original post

7 Replies
vamsee
Specialist
Specialist

Try

Dataset1:
LOAD * INLINE [
PN, Day1, Day2, Day3
1234, 3, 4, 5
2345, 10, 12, 10
3456, 9, 8, 7
5678, 6, 8, 8
9876, 5, 6, 8
]
;
Concatenate
Dataset2:
LOAD * INLINE
PN, Day1, Day2, Day3
9981, 3, 4, 5
6671, 10, 12, 10
5674, 9, 8, 7
1234, 10, 10, 10
2345, 20, 20, 20

]
;
Result:
NoConcatenate
LOAD
PN,
SUM(Day1) as Day1,
SUM(Day2) as Day2,
SUM(Day3) as Day3
Resident Dataset1
Group by PN;
DROP Table Dataset1;

Anonymous
Not applicable

Hi,

Do you want to do it in the script or on the UI ?

I think it is better to do it in the UI, you just have to create a table in the graphs, then put PN and Days as dimension, the expression should be

sum(Day1)+sum(Day2)+sum(Day3)

poluvidyasagar
Creator II
Creator II
Author

I want to do it in loading script.

vishsaggi
Champion III
Champion III

Try this:

Dataset1:

LOAD * INLINE [

PN, Day1, Day2, Day3

1234, 3, 4, 5

2345, 10, 12, 10

3456, 9, 8, 7

5678, 6, 8, 8

9876, 5, 6, 8

];

 

Dataset2:

LOAD * INLINE [

PN, Day1, Day2, Day3

9981, 3, 4, 5

6671, 10, 12, 10

5674, 9, 8, 7

1234, 10, 10, 10

2345, 20, 20, 20

];

NoConcatenate

Final:

LOAD PN,

     Sum(Day1) AS Day1,

     Sum(Day2) AS Day2,

     Sum(Day3) AS Day3

Resident Dataset1

Group By PN;

Drop Table Dataset1;

Anonymous
Not applicable

Then when 2 tables have the same fields, QlikView automatically concatenate the 2 tables.

So you just have to create a new table in which you use sum(DAYS_FIELD) with a group by PN (dont forget to use NO CONCATENATE) otherwise this new table will be added concatenate to the old one also.

poluvidyasagar
Creator II
Creator II
Author

Thanks Vamsee. It worked

poluvidyasagar
Creator II
Creator II
Author

Thanks Vishwa. It worked.