Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have a problem with some survey data which I'm not sure how to process before I load it into Qlikview.
My data is downloaded from the back end of an online survey where we allow multiple answers to be selected for some of the questions.
The data ends up similarly to the example below (see favourite colours):
Name | Favourite Colours | Favourite shape |
James | Blue, Red, Green | circle |
Peter | Red, Yellow, White | rectangle |
Henry | Blue, White, Orange | triangle |
George | Green, Blue, Red | rectangle |
Fred | White, Yellow | rectangle |
Steve | Red | triangle |
Jordan | Blue, Green | circle |
I'm not sure what the best way to process this data is.
I've heard that a good option might be to do the following... but with several questions allowing multiple answers the final database might end up huge!
Name | Favourite Colours | Favourite shape |
James | Blue | circle |
James | Red | circle |
James | Green | circle |
Peter | Red | rectangle |
Peter | Yellow | rectangle |
Peter | White | rectangle |
Henry | Blue | triangle |
Although this might work in principle... i can still see there being issues when finished, ie any 'count' field would be out...
Also, the survey doesnt specify that they NEED to select 3 answers, only that they can select upto... so I'd end up with different numbers of lines for each entry...
Any help would be really appreciated - I'm pretty stumped with this one.
Andrew
Try using SUBFIELD Function in the Script
So it would be
SUBFIELD([Favourite Colours],',') AS [Favourite Colours]
Regards
Al
If your concern is regarding the Count function, then you can always use "Count(Distnct 'field')" for getting unique record count.
I would have split your preferences on one table for each question. In this case. One ShapePreference dimension (If it is possible that a person may have more than one favorite shape) and one ColorPreference dimension.
With this solution you may calculate how many colors each person prefer. how many persons prefere a color etc.
I provide a qvw-example.
subfield function could be a part of the solution. To be true I am not sure what the full solution will be. I am curious to know the solution.
thanks,
Rajesh Vaswani
Try using SUBFIELD Function in the Script
So it would be
SUBFIELD([Favourite Colours],',') AS [Favourite Colours]
Regards
Al
I used the subfield-function in my example.
Hi Alan, I think I like the way you're going here.
Sorry to be a complete novice, but could you give a brief overview of how the function works?
Kind regards,
Andrew
Thanks for taking the time to do this, really useful, great solution thanks very much!
Further to the note I just added, I've just taken a look at the Subfunction field and I'm not sure how I could alter it to suit the data, but you might know a way?
My understanding is that if I used the subfuntion field, I would effectively split out the favourite colours into 3 columns, the problem would then be bringing them all back together so that I could then filter for example 'blue' and show all respondents with blue listed (whether they put it first, second or third)
Not sure if anyone can help here?
Many thanks,
Andrew
If you use the subfield function with only two parameters, i.e. fieldname and separator, then a new record will be created for every value in the list. That also means that it doesn't get confused if there are two, four or ten (comma) separated values. Every value in the list will end up in its own record but in the same column. Just like the result table example you posted.
SurveyData:
Load
Name,
subfield([Favourite Colours],',') as [Favourite Colours],
[Favourite shape]
From ...mysource...;
Also your qlikview document will not explode in size (unless you have exceptionally large number of records to begin with). See this blog post for an explanation:Symbol Tables and Bit-Stuffed Pointers