Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
D19PAL
Creator II
Creator II

How do i do an if statement

Hi,

How do i do this if statement as a flag perhaps.

Data

ID,Student,Teacher,Class,Position

1,John,James,Art,student

2,James,Paul,Art,Teacher

3,Sue,James,Art,student 

4,Mark,Paul,Maths,student 

The if statment

If student and teacher have the same class,  so John and Sue have Art with James, so the count in the flag will be 3.

 

Thanks

 

 

Labels (1)
1 Reply
ajaykakkar93
Specialist III
Specialist III

hi,

no need for an if statement there are two ways
first, make a key field like below
Student&'-'&Teacher as Student_Teacher_Key;


If you want to do it in the Backend script:

data1:
//step 1
load ID,Student,Teacher,Class,Position,
Student&'-'&Teacher as Student_Teacher_Key;
load * Inline [
ID,Student,Teacher,Class,Position
1,John,James,Art,student
2,James,Paul,Art,Teacher
3,Sue,James,Art,student
4,Mark,Paul,Maths,student
];


data2:
load Class,Count(Student_Teacher_Key) as cuontOfStudent_Teacher_Key
Resident data1
Group by Class;


exit Script;

Just do 
sum(cuontOfStudent_Teacher_Key)
in frontend


If you want to do it in the Front end  script:

data1:
//step 1
load ID,Student,Teacher,Class,Position,
Student&'-'&Teacher as Student_Teacher_Key;
load * Inline [
ID,Student,Teacher,Class,Position
1,John,James,Art,student
2,James,Paul,Art,Teacher
3,Sue,James,Art,student
4,Mark,Paul,Maths,student
];


exit Script;

Just do 
count(Student_Teacher_Key)
in frontend



Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting