Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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
You want rename a field then you could use the rename-statement(s) - have a look in help.
- Marcus
Unfortunately its proposal will not work, I have many question fields to treatment individually.
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
Marcus this information is related to an investigation of these we respond when we are approached by field researchers. Like this:
QUESTIONS | ANWSERS |
---|---|
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;
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