Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING
cancel
Showing results for 
Search instead for 
Did you mean: 
Akaszon
Contributor II
Contributor II

Survey responses presented in horizontal stacked bar

Hello,

I've survey responses presented like in below (multiple participants, multiple questions, 3 options to choose from per each question):

IDQuestion_1Question_2Question_3
101AgreeDon't KnowDon't Agree
102AgreeAgreeDon't Know
103Don't AgreeDon't AgreeDon't Agree

 

I would like to have the data for each question presented as horizontal stacked bar summing up to 100% (one bar per one question), similarily as below:

Akaszon_0-1617812292863.png

Could anyone help me/direct in a right way on how to achieve this form of presenting the results?

Thank you in advance

1 Solution

Accepted Solutions
mato32188
Specialist
Specialist

Hi Akaszon,

first adjust your script using CrossTable syntax function similar to:

table:
CrossTable(Question, Answer, 1)

load * Inline [
ID,Q1,Q2,Q3
1,Agree,Don't Know,Don't Agree
2,Agree,Agree,Don't Know
3,Don't Agree,Don't Agree,Don't Agree
];

Then create stacked horizontal bar chart using:

Dim (stack): Question

Dim (bars): Answer

Measure: Count(Answer)/count(total <Question>Answer)

Formatting in percentage.

mato32188_0-1617823025946.png

Hope it helps.

BR

m

 

 

ECG line chart is the most important visualization in your life.

View solution in original post

5 Replies
mato32188
Specialist
Specialist

Hi Akaszon,

first adjust your script using CrossTable syntax function similar to:

table:
CrossTable(Question, Answer, 1)

load * Inline [
ID,Q1,Q2,Q3
1,Agree,Don't Know,Don't Agree
2,Agree,Agree,Don't Know
3,Don't Agree,Don't Agree,Don't Agree
];

Then create stacked horizontal bar chart using:

Dim (stack): Question

Dim (bars): Answer

Measure: Count(Answer)/count(total <Question>Answer)

Formatting in percentage.

mato32188_0-1617823025946.png

Hope it helps.

BR

m

 

 

ECG line chart is the most important visualization in your life.

View solution in original post

Akaszon
Contributor II
Contributor II
Author

Hi Mato,

Many thanks for your answer.

About the CrossTable - is there any "automated" way to include all answers given to certain question? It sure can be done manually for 3 participants, but what if I have 100 participants?

mato32188
Specialist
Specialist

Hi @Akaszon,

it is not a problem for crosstable syntax function. Check Qlik help site: https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

BR

ECG line chart is the most important visualization in your life.
Akaszon
Contributor II
Contributor II
Author

Hi @mato32188 ,

I checked this link on Qlik help, but couldn't really find any information on how can I populate the "load * inline" part with all records falling under certain category (following the example that you've posted - instead of "1,2,3" I would like to have all the records stored as "Identifiers" in the data file that I've uploaded).

Still, I was able to paste the larger population manually and create the stacked bar, just the way you showed:

Akaszon_0-1617899830825.png

Thank you 🙂

 

mato32188
Specialist
Specialist

Hi @Akaszon ,

instead of using "load inline", you can use standard load from any file, database or whatever supported by Qlik.

Script could look like:

CrossTable(Question, Answer, 1)

Load

Id,

Q1,

Q2,

Q3,

...

from "file", "db table", etc.;

BR

m

ECG line chart is the most important visualization in your life.