3 Replies Latest reply on Oct 2, 2017 7:13 AM by Chuck Collins

# Count for Number of Time Answer Choice is Selected

Hi All:

This for an identity question on a survey where the respondants could choose any combination of sexual orientations. It's a dataset that I inherited and it's pretty messy, but they are sorted by responseID.

Responses are as below, what I want to do is count the number of times that someone selected bisexual, asexual, etc.

I started with else if series but that excludes respondents once the choice is processed. (see below)

Thoughts on the best way to accomplish this count?

Calculated Field:

IF CONTAINS([Q7],"Heterosexual") THEN "Heterosexual"

ELSEIF CONTAINS([Q7], "Bisexual") THEN "Bisexual"

ELSEIF CONTAINS([Q7], "Gay") THEN "Homosexual / Gay - Male Partners"

ELSEIF CONTAINS([Q7], "Lesbian") THEN "Homosexual / Lesbian - Female Partners"

ELSEIF CONTAINS([Q7], "Asexual") THEN "Asexual"

ELSEIF CONTAINS([Q7], "Pansexual") THEN "Pansexual"

ELSEIF CONTAINS([Q7], "Questioning") THEN "Questioning or Unsure"

ELSEIF CONTAINS([Q7], "Other") THEN "Other"

END

Response Combinations of Data from Select All that Apply Question:

• ###### 1. Re: Count for Number of Time Answer Choice is Selected

Hi Chuck

Please attach your packaged workbook, or at least sample data by excel or something.

Thanks

Shin

• ###### 2. Re: Count for Number of Time Answer Choice is Selected

Just a quick thought: Would it work for you to create a bunch of separate measures? So:

Heterosexual Count:

IF CONTAINS([Q7],"Heterosexual") THEN 1 else 0 END

Bisexual Count:

IF CONTAINS([Q7],"Bisexual") THEN 1 else 0 END

Etc.

Then when you put it in the view you can sum them.

Columns with a string of varying values are a tough nut to crack.

I wonder if Tableau would let you then pivot these calculated fields... You know on the data tab, if you're using Excel, you can select some columns, then right-click and choose pivot. Never tried to do it with a calculated field so I don't know if it would work.

Good luck,

Jennifer

1 of 1 people found this helpful
• ###### 3. Re: Count for Number of Time Answer Choice is Selected

Hi Jennifer,

This is what I ended up doing. Thanks for the note!

Chuck