Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
pepe2209
Creator
Creator

Make groups based on starting point for new group

Hello

please look at the table below. I want to create te last column via the script.

IDNewgroupGroupTEMPGroupCode
1Yes11
21

3

1
4Yes22
5Yes33
63
73
83
93
10Yes44

the table is ordered by ID. As long as Newgroup<>Yes then the GroupCode should be the last known GroupTEMP where Newgroup=Yes.

So how can i create this GroupCode in the script?

Your help would be much appreciated.

Regards,

Peter

1 Solution

Accepted Solutions
Not applicable

Hello Peter,

Please try below script:

Table1:
Load *, IF(WildMatch(NewGroup,'Yes')=1,GroupTEMP,Peek(GroupCode)) as GroupCode;
LOAD * INLINE [
ID, NewGroup, GroupTEMP
1, Yes, 1
2
3
4, Yes, 2
5, Yes, 3
6
7
8
9
10, Yes, 4
]
;

Output:

   

IDNewGroupGroupTEMPGroupCode
1Yes11
2 1
3 1
4Yes22
5Yes33
6 3
7 3
8 3
9 3
10Yes44

View solution in original post

3 Replies
Not applicable

Hello Peter,

Please try below script:

Table1:
Load *, IF(WildMatch(NewGroup,'Yes')=1,GroupTEMP,Peek(GroupCode)) as GroupCode;
LOAD * INLINE [
ID, NewGroup, GroupTEMP
1, Yes, 1
2
3
4, Yes, 2
5, Yes, 3
6
7
8
9
10, Yes, 4
]
;

Output:

   

IDNewGroupGroupTEMPGroupCode
1Yes11
2 1
3 1
4Yes22
5Yes33
6 3
7 3
8 3
9 3
10Yes44

Not applicable

Hello Peter,

Is that script working as you expected.

Thanks,

Uday.

pepe2209
Creator
Creator
Author

Hello Uday,

I just tested your script and it works perfect.

Thanks!