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

Get FieldName in other table Load

Hi!

I have table like this:

BASE:

LOAD

     Id,

     Question1,

     Question2,

     Question3,

     .,

     .,

     .

From [CSVFILES.CSV] ();

The fields Questionx (like this: You have a car?), is a simple anwser (Yes/No)

I must "transform" the fields named "Questionx" to Question and renamed field Questionx  to anwser.

I try someting like this:

1) I Create a map table from Question LOAD * INLINE [QuestionId, Question ....];

2) LET = QuestionId = 0;

FOR EACH vQuestion In $(vQuestions)

  LET = QuestionId = QuestionId + 1;

  LOAD

  RowNo(),

  $(QuestionId)                                                                                                                 as QuestionId,

  FieldValue(FieldName(FieldNumber('$(vQuestion )', 'BASE'), 'BASE'), RowNo())     as Anwser

  RESIDENT BASE

  WHERE FieldName(FieldNumber('$(vQuestion )', 'BASE'), 'BASE') = '$(vQuestion)'

  ;

NEXT

But, The anwser field return null.

can anyone help me?

1 Solution

Accepted Solutions
marcus_sommer

If the questions is the field-name then you could transform it with crosstable:

http://community.qlik.com/blogs/qlikviewdesignblog/2014/03/24/crosstable

- Marcus

View solution in original post

5 Replies
marcus_sommer

You want rename a field then you could use the rename-statement(s) - have a look in help.

- Marcus

MarcoARaymundo
Creator III
Creator III
Author

Unfortunately its proposal will not work, I have many question fields to treatment individually.

marcus_sommer

If I look on your load-statement you might need to load your data with a crosstable-statement to transform your crosstable into a data-stream.

- Marcus

MarcoARaymundo
Creator III
Creator III
Author

Marcus this information is related to an investigation of these we respond when we are approached by field researchers. Like this:

QUESTIONSANWSERS
You Have a Car?YES / NO
You Have a Bike?YES / NO
Do you drink a beer?YES / NO
What is your favorite beer?XYZ K2

CSV files bring the same information in the same way, that is, the question is the field name.

What I want is to create a new table with a QuestionID field where I can identify what's the question (1, 2, 3 etc) and this answer.

I have a table where the questions are mapped.

An example of the table is:

LOAD

     Field1,

     Field2,

     Field3,

     Field4,

     QuestionId,

     Anwser

FROM CSVFiles;

marcus_sommer

If the questions is the field-name then you could transform it with crosstable:

http://community.qlik.com/blogs/qlikviewdesignblog/2014/03/24/crosstable

- Marcus