Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
tfc
Partner - Contributor
Partner - Contributor

Adding values to more than one field

Suppose I have a list of students and the courses they're taking. The courses they are taking are in all one field separated by '/' for each student for example:

Name                     Id                       Courses

Example               1234                  C/C++/Java/Python

And I want to make a bar chart to show the popularity of these courses (how many students are taking each course). How can I add more than 1 value in the expression editor so that for the above example, the magnitude of the bars corresponding to C, C++, Java and Python all increase by 1 when a student has taken these 4 courses?

Labels (3)
4 Replies
DavidM
Partner - Creator II
Partner - Creator II

I think right way to go is to create line for each of the courses with subfield in load script:

If(Index(Courses,'/')>0,Subfield(Courses,'/'),Courses) as Courses

asinha1991
Creator III
Creator III

maybe

Subfield(Courses,'/') as chart dimension and count(distinct ID) as expression work

durgesh22
Creator
Creator

Temp:
load * Inline
[
Name,Id,Course
A,1,C/C++/Java/Python
B,2,Nodejs/Python
C,3,Nodejs/Java/Python
];
Final:
load Name,Id,SubField(Course,'/') as SingleCourse resident Temp;
drop Table Temp;

Hope above code helps to solve you problem.

 

sugathirajkumar
Creator
Creator

Tab2:
LOAD *
Inline [

Name , Id , Courses

sugan , 1234 , C/C++/Java/Python
raj , 1235 , C/C++/Java,
athira , 1236 , C/C++
lak , 1237 , Java

];

for i=1 to 4

Tab3:

LOAD *, SubField(Courses,'/',$(i)) as coursenew

Resident Tab2 ;


NEXT i;
drop table Tab2;
exit Script;

 

 

clipboard_image_0.png