Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Data fields with multiple entries

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):

NameFavourite ColoursFavourite shape
JamesBlue, Red, Greencircle
PeterRed, Yellow, Whiterectangle
HenryBlue, White, Orangetriangle
GeorgeGreen, Blue, Redrectangle
FredWhite, Yellowrectangle
SteveRedtriangle
JordanBlue, Greencircle

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!

NameFavourite ColoursFavourite shape
JamesBluecircle
JamesRedcircle
JamesGreencircle
PeterRedrectangle
PeterYellowrectangle
PeterWhiterectangle
HenryBluetriangle

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

1 Solution

Accepted Solutions
rustyfishbones
Master II
Master II

Try using SUBFIELD Function in the Script

So it would be

SUBFIELD([Favourite Colours],',') AS [Favourite Colours]

Regards

Al

View solution in original post

13 Replies
Not applicable
Author

If your concern is regarding the Count function, then you can always use "Count(Distnct 'field')" for getting unique record count.

Vegar
MVP
MVP

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.

rajeshvaswani77
Specialist III
Specialist III

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

rustyfishbones
Master II
Master II

Try using SUBFIELD Function in the Script

So it would be

SUBFIELD([Favourite Colours],',') AS [Favourite Colours]

Regards

Al

Vegar
MVP
MVP

I used the subfield-function in my example.

Not applicable
Author

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

Not applicable
Author

Thanks for taking the time to do this, really useful, great solution thanks very much!

Not applicable
Author

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

Gysbert_Wassenaar

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


talk is cheap, supply exceeds demand