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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Sum based on row value

My input is 

Balls,Valid Ball,Runs
1,Y,0
2,Wide Ball,1
3,No Ball,4
4,Y,2
5,Y,6
6,Y,0
7,Wide Ball,1
8,Wide Ball,1
9,Y,4
10,Y,4
11,Y,6
12,Y,0
13,Y,0
14,No Ball,1
15,No Ball,1
16,Wide Ball,4
17,Wide Ball,3
18,Y,6
19,Y,6
20,Y,6

 

Need Output as

over,runs

1,23

2,33

Labels (3)
7 Replies
TRF
Champion II
Champion II

Do we have to guess the logic for going from the input to the output?

Anonymous
Not applicable
Author

oops..forgot to mention that

Over is of 6 Balls, Count 6 Valid Balls for 1 Over.'Y' means its a valid ball

TRF
Champion II
Champion II

Sorry, I don't play cricket, just play Talend!
Can give more details?
Anonymous
Not applicable
Author

0683p000009MACn.png

need to sum the runs column for 1st 6 'Y's (need to include no ball, wide which comes within 1st 6 valid balls) then for the 2nd 6  'Y's and so on

TRF
Champion II
Champion II

Here is my proposal:

0683p000009M88e.png

You need some logic with tMap local variables:

0683p000009M88j.png

Sum are computed with tAggregateRow component with the following settings:

0683p000009M88o.png

And the result is:

Starting job test at 11:00 08/10/2019.

[statistics] connecting to socket on port 4014
[statistics] connected
.----+----.
|tLogRow_13|
|=---+---=|
|over|runs|
|=---+---=|
|1   |23  |
|2   |33  |
'----+----'

[statistics] disconnected
Job test ended at 11:00 08/10/2019. [exit code=0]
Anonymous
Not applicable
Author

can you please help me with  the logic used in the tmap.

TRF
Champion II
Champion II

No time for detailed explications.
You have to know local variables are evaluated in the order they are defined.
Start by copying to your job for test then try to decompose manually step by step, it's the better approach to learn (maybe using paper and pen).

Also don't forget to mark your case as solved (Kudos also appreciated).