How to visualize multiple answer questions in tableau

Viewed 287

I have a question, How do you handle and visualise multiple answer questions in tableau. If you have a dimension Could you please tell us where we need to improve? and the questions and the choices are

Explosives, Wireless

Vehicles

enter image description here

Cement, Vehicles.

I want to calculate the no of times vehicles is selected in the answer. How do I do that?

2 Answers

One way is to define a calculated field as below that has the value 1 for data records that contain the string "vehicles" in the field [My Field], regardless of which characters are upper or lower case. Let's Say you call this calculated field Has Vehicles

int(contains(lower([My Field]), “vehicles”))

Then if you drag the calculated field you just defined to a shelf as a measure, then you can count the number of records that contain that string, with the aggregation function, SUM - as in SUM([Has Vehicles])

You can use the field as dimension or filter instead to separate records that have vehicles from those that don't. Or use other aggregation functions to determine the percentage of records that have vehicles, using AVG() instead of SUM(), since the the field only has values 0 or 1. Or use MIN() or MAX() or STDEV() etc.

You can also use a parameter for your text string to allow the user to type or choose different strings, instead of hard coding it to the string "vehicles"

For more complex text analytics, consider using regular expression functions instead of contains, or doing some pre-processing with Tableau Prep, Python or other tools to clean and normalize the text data up front.

As there are up to 6 separated values, using this link, https://www.flerlagetwins.com/2020/05/split-and-pivot.html, you need to split and union the data.

Splitting the field will produce 6 new fields.

Union the table to itself 6 times, then write a new calculated field to bring back 1 of the "splits" per union. In the link it is something like:

CASE [Table Name]
WHEN "Events" THEN [Split 1]
WHEN "Events1" THEN [Split 2]
WHEN "Events2" THEN [Split 3]
...
WHEN "Events5" THEN [Split 6]
END

Looking at your data you will also have to tdy the values, removing "" and spaces. Look at the TRIM and REPLACE functions.

Related