Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
ontoit7331
Contributor II
Contributor II

Count a value of a field between two other values

Hello,

I need to count all the values between two other values.

for example:

This is the rows i wanna read from an excel

TimeStartValueName
07:00Y John
08:00 1 
09:00 2 
10:00 4 
11:00Y Robert
12:00 2 
13:00 2 
14:00 10 

 

I want the table to look like this when it's done:

NameValue
John7
Robert14

 

Is there by any chance  possible to count the values between the Start Time and the next Start Time?

Sorry for my grammar.

Thanks in advance.

Best regards,

Robin

1 Solution

Accepted Solutions
Taoufiq_Zarra

maye be :

Data:

load 

Time,
Start,
Value,
if( len( trim(Name) ) = 0, peek(Name), Name)  as Name
;

LOAD * INLINE [
Time,Start,Value,Name
07:00,Y,,John
08:00,,1,
09:00,,2,
10:00,,4,
11:00,Y,,Robert
12:00,,2,
13:00,,2,
14:00,,10,
];



output:
noconcatenate
load 
Name,
Sum(Value) as Value

resident Data
group by Name;


drop table Data;

 

 output :

Capture.JPG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

4 Replies
Taoufiq_Zarra

maye be :

Data:

load 

Time,
Start,
Value,
if( len( trim(Name) ) = 0, peek(Name), Name)  as Name
;

LOAD * INLINE [
Time,Start,Value,Name
07:00,Y,,John
08:00,,1,
09:00,,2,
10:00,,4,
11:00,Y,,Robert
12:00,,2,
13:00,,2,
14:00,,10,
];



output:
noconcatenate
load 
Name,
Sum(Value) as Value

resident Data
group by Name;


drop table Data;

 

 output :

Capture.JPG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
ontoit7331
Contributor II
Contributor II
Author

Thank you very much, it works! 🙂

sergio0592
Specialist III
Specialist III

Hi,

Can you explain : peek(Name), Name ?

Thanks

Taoufiq_Zarra

Hi, to fill the null values with the previous values
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉