Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
kasmi
Contributor
Contributor

Stacked bar chart multiple ordinal variables

Hello everyone,

I'm quite new in Qlik Sense and I have trouble representing multiple ordinal variables in a stacked bar chart.

I have data from a survey on the motivations to enter vocational training. The interviewees had to answer on a scale of agreement (strongly disagree, disagree, agree, strongly agree) to several statements about motivation. 

Attached, a simplified version of how my database looks like and the stacked bar chart I would like to produce.

How can I do that? Maybe I have to change the way my database is built?

Kind regards,

Catherine

 

Labels (2)
6 Replies
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Catherine,

I'd suggest using a mapping to convert your text values to dual values

https://help.qlik.com/en-US/qlikview/12.1/Subsystems/Client/Content/Scripting/FormattingFunctions/Du...

these allow you to define a field with a text display and an underlying numerical value (useful for sorting!)

 

For example you may define a mapping table as

MotivMap:

MAPPING LOAD * INLINE [

Motiv, MotivValue

Strongly Disagree, 1

Disagree, 2

Agree, 3

Strongly Agree, 4

];

 

Then, when loading your data

LOAD

Survey

Dual(Motiv1, ApplyMap('MotivMap', Motiv1)) as Motiv1,

etc, etc..

 

Hope this helps,

 

Marcus

juliensaintmaxent3113
Luminary Alumni
Luminary Alumni

hi,

in attachment, you find the app wiht:

script : i use cross table to pivot the table

sheet: an example of bar chart

however, you don't show each value in the graphic like your picture

Bye

kasmi
Contributor
Contributor
Author

Thanks Marcus and jsaintmaxent, both replies are very useful ! Now I have to figure out how to replicate it (Script is quite new for me) and when I'm done, I'll update the post!

Catherine

kasmi
Contributor
Contributor
Author

I managed to replicate it. There is no other way to do this without 'unpivoting' the table (crosstab), right?

kasmi
Contributor
Contributor
Author

Thanks, this mapping function is very useful in general but it does not help me to do the graph. It seems that I have to unpivot (crosstab) my table.

juliensaintmaxent3113
Luminary Alumni
Luminary Alumni

i think,you can try with the function if but it's so long and inefficientand if you have got a new value, you will modify the script