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

How to define the below Logic in Qlikview Load Script

Hello All,

I have a Table with the following Details:

Raw Data:

QuestionNumberAnswerNumberAnswerText
1510
1511
140202
150302
160303

Expected Result:   

  

QuestionNumberAnswerNumberAnswerText
1510
14010
15010
16010
1511
140202
150302
160303

Basically, If the QNo 15 has ANo 1 and all the other QNo have no entries(or Null Values) i should fill up 0 against the AnswerNumber and AnswerText. If there are Values against each QNO, they should remain as is.

Note: This Should be generated at the script level as i have to further use this Table.

TIA!!

Nachricht geändert durch Pakalapati Sai Kumar

8 Replies
Digvijay_Singh

You may try 'fill' in transformation steps while loading the table. The other way could be using previous function with some condition through resident load.

LOAD QuestionNumber,

     AnswerNumber,

     AnswerText

FROM

[https://community.qlik.com/thread/299416]

(html, codepage is 1252, embedded labels, table is @1, filters(

Replace(2, top, StrCnd(null)),

Replace(3, top, StrCnd(null))

));

YoussefBelloum
Champion
Champion

Hi,

try this code:

RawData:

LOAD QuestionNumber,

     if(len(trim(AnswerNumber))=0, 'fill_zero',AnswerNumber) as AnswerNumber,

     if(len(trim(AnswerText))=0, 'fill_zero',AnswerText) as AnswerText

    

FROM

[https://community.qlik.com/thread/299416]

(html, codepage is 1252, embedded labels, table is @1);

with this, you will be able to see the difference between the original 0 and the cells that you fill in the script.

if it is ok for you, just replace the 'fill_zero' with 0

MarcoWedel

Hi,

maybe one solution could be:

QlikCommunity_Thread_299416_Pic1.JPG

table1:

LOAD QuestionNumber,

    If(Len(Trim(AnswerNumber)),AnswerNumber,Peek(AnswerNumber)) as AnswerNumber,

    If(Len(Trim(AnswerText)),AnswerText,Peek(AnswerText)) as AnswerText

FROM [https://community.qlik.com/thread/299416] (html, codepage is 1252, embedded labels, table is @1);

hope this helps

regards

Marco

shiveshsingh
Master
Master

You can define null field as zero, put condition accordingly while load script

psk180590
Creator III
Creator III
Author

Hello All,

Just to be more clear, have attached sample data and the expected result

psk180590
Creator III
Creator III
Author

Corrected the data, this one is more what i'm looking at.

sasiparupudi1
Master III
Master III

why the rows are not repeated for the example 3?

   

QuestionNumberAnswerNumberAnswerText
Example1:
1510
14000
15000
16000
Example 2:
1511
140202
150302
160303
Example 3:
1500
psk180590
Creator III
Creator III
Author

Let me explain the question a little bit more

Say, there is a Survey where QNo 1 has to be answered with Two Options 1 or 2. When the User selects 2, they are allowed to Answer  further Questions like QNo 2 with Answer 3,4,5.....

But, if the User Selects Answer 1 for QNo1, the survey ends with only one Answer.

Now, here i'm looking to populate all the other QNo's with the same answer as for QNo(1 in this case).