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

Fill missing data

Hi,

Can this be done in Qlik ?

Source Data (table): 

Personcoursestatus
11c1complete
11c2In-progress
22c1complete

 

Anticipated Result (Pivot on Course):

I am try to pivot on course. Person# 22 is not required to take the course C2 and he does not have records in source feed. My goal in the report is to display "not applicable" or some text and not a dash (-).

 C1C2
Person  
11completeIn-progress
22completeNot applicable

 

Note: It is hard for us to load and maintain a table for all not-applicable scenarios.  Checking it to see whether it can be dynamically handled with in the Qlik report. 

Appreciate your help. Thank you!! 

Labels (1)
3 Replies
gbommisetti
Contributor II
Contributor II

Table:
LOAD * INLINE [

Person, course, status
11, c1, complete
11, c2, In-progress
22, c1, complete

];
courses:

Load Distinct course as course Resident Table;

Let vTemp = FieldValueCount('course');

For i=0 to vTemp-1

Let vTemp2 = Peek('course',$(i),'courses');


Final:

Load

Person,
status as '$(vTemp2)'
Resident Table
Where course = '$(vTemp2)'
;

Next

Drop Table courses;

CombineTable:

Load Distinct Person Resident Table;

Drop Table Table;

FOR i = NoOfTables()-1 to 0 STEP -1

LET vTable = TableName($(i));

IF WildMatch('$(vTable)', 'Final*') THEN

LEFT JOIN ([CombineTable]) LOAD * RESIDENT [$(vTable)];

DROP TABLE [$(vTable)];

ENDIF

NEXT i

NullAsValue *;

Set NullValue = 'Not applicable';
NoConcatenate
Test:
load *
Resident CombineTable;

drop Table CombineTable;

Santsoh_Qlik
Contributor
Contributor
Author

Hi,

Thank you for your response. There are 100's of courses and can not create a column for each course.

If handling in the data model is the best way, then I would prefer below. 

Personcoursestatus 
11c1complete 
11c2In-progress 
22c1complete 
22c2Not applicableNew row

 

gbommisetti
Contributor II
Contributor II

Table:
LOAD * INLINE [

Person, course, status
11, c1, complete
11, c2, In-progress
22, c1, complete

];
Table2:
load distinct course
resident Table;
join
load distinct Person
resident Table;

Table3:
NoConcatenate
load *
Resident Table;
right join
load *
Resident Table2;

final:
NoConcatenate
load Person,
course,
if(isnull(status)=0 and status <> '',status,'Not Applicable') as status
Resident Table3;

drop tables Table,Table2,Table3;