Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rajeshqvd
Creator II
Creator II

Finding Cycles

Hi,

I need below req' in Qlik.

 

Thanks,

 

ID Data Output Output should be
222 AB Cycle1 Cycle1
222 AB Cycle2 Cycle2
222 AB Cycle3 Cycle3
222 e Cycle4 Cycle3
222 ffg Cycle4 Cycle3
222 aa Cycle4 Cycle3
222 ff Cycle4 Cycle3
222 df Cycle4 Cycle3

but in other scenario it coming correctly
ID Data Output
111 a Cycle1
111 b Cycle1
111 c Cycle1
111 d Cycle1
111 AB Cycle1
111 j Cycle2
111 k Cycle2
111 AB Cycle2
111 kl Cycle3
111 hg Cycle3
111 hgg Cycle3
111 AB Cycle3

Labels (1)
17 Replies
Channa
Specialist III
Specialist III

if(match('222'),'111')

 

try

Channa
sunny_talwar

Can you explain what is going on?

rajeshqvd
Creator II
Creator II
Author

This is the Data
ID Data
111 a
111 b
111 c
111 d
111 AB
111 j
111 k
111 AB
111 kl
111 hg
111 hgg
111 AB
222 a
222 c
222 d
222 e
222 AB
222 aa
222 ff
222 AB
this is required Output
Output
Cycle1
Cycle1
Cycle1
Cycle1
Cycle1
Cycle2
Cycle2
Cycle2
Cycle3
Cycle3
Cycle3
Cycle3
Cycle1
Cycle1
Cycle1
Cycle1
Cycle1
Cycle2
Cycle2
Cycle2
sunny_talwar

What is the logic here?

rajeshqvd
Creator II
Creator II
Author

Last time we tried this
LOAD RowNo() as RowNum,
*,
If(ID = Previous(ID), If(Previous(Data) = 'AB', RangeSum(Peek('CycleNum'), 1), Peek('CycleNum')), 1) as CycleNum,
'Cycle' & If(ID = Previous(ID), If(Previous(Data) = 'AB', RangeSum(Peek('CycleNum'), 1), Peek('CycleNum')), 1) as Output;
LOAD * INLINE [
ID, Data
111, a
111, b
111, c
111, d
111, AB
111, j
111, k
111, AB
111, kl
111, hg
111, hgg
111, AB
222, a
222, c
222, d
222, e
222, AB
222, aa
222, ff
222, AB
];
but above mentioned mismatch coming .
rajeshqvd
Creator II
Creator II
Author

if starting 3 rows has AB value it should show lik 3 cycles but it showing 4 cycles
Channa
Specialist III
Specialist III

when cycle3,and cycle 2 should start

Channa
rajeshqvd
Creator II
Creator II
Author

based on( Data = 'AB' is 1 cycle)
sunny_talwar

This is what I get when I run your script... what is the issue?

image.png