Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
mohan23911
Contributor
Contributor

If condition in where clause - script

Hi, in the below sample data can you please help me in loading only the required data

INPUT

ID Code Value
1 TAC_FX 10
1 TAC 15
2 TAC_FX_ADJ 20
2 TAC_ADJ 25
3 TAC 35
4 TAC_ADJ 40
5 TTT 50

 

OUTPUT

ID Code Value
1 TAC_FX 10
2 TAC_FX_ADJ 20
3 TAC 35
4 TAC_ADJ 40

 

basically, the idea is like, Qlik should check and load 

- the records which contain TAC_FX, TAC_FX_ADJ, first

- if these are not presented, then it should check for the records containing TAC, TAC_ADJ

else it should not fetch.

Kindly assist me, Thank You

Labels (4)
1 Solution

Accepted Solutions
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

 

You can try a script like this :

 

Data:
Load
*
Inline [
ID, Code, Value
1, TAC_FX, 10
1, TAC, 15
2, TAC_FX_ADJ, 20
2, TAC_ADJ, 25
3, TAC, 35
4, TAC_ADJ, 40
5, TTT, 50
];

Data2:
Load
*,
ID as ID_EXIST
Resident Data
Where
Match(Code, 'TAC_FX', 'TAC_FX_ADJ')
;


Concatenate(Data2)
Load
*,
ID as ID_EXIST
Resident Data
Where
not Exists(ID_EXIST, ID)
and Match(Code, 'TAC', 'TAC_ADJ')
;


Drop Table Data;

Help users find answers! Don't forget to mark a solution that worked for you!

View solution in original post

1 Reply
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

 

You can try a script like this :

 

Data:
Load
*
Inline [
ID, Code, Value
1, TAC_FX, 10
1, TAC, 15
2, TAC_FX_ADJ, 20
2, TAC_ADJ, 25
3, TAC, 35
4, TAC_ADJ, 40
5, TTT, 50
];

Data2:
Load
*,
ID as ID_EXIST
Resident Data
Where
Match(Code, 'TAC_FX', 'TAC_FX_ADJ')
;


Concatenate(Data2)
Load
*,
ID as ID_EXIST
Resident Data
Where
not Exists(ID_EXIST, ID)
and Match(Code, 'TAC', 'TAC_ADJ')
;


Drop Table Data;

Help users find answers! Don't forget to mark a solution that worked for you!