Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
Taka4
New Contributor II

How to create a stacked bar chart with multiple columns on Qlik

I am trying to create a stacked bar chart on Qlik from a dataset shown below. The chart should look like a picture below. (I apologize about the quality). I watched a couple of tutorials, but their dataset had a different organization... Should I also revise my dataset to create this stacked bar chart? Please let me know if you have any questions. Thank you so much for taking your time.
IMG_C10FB0916A0A-1.jpegScreen Shot 2019-03-01 at 6.27.20 PM.png
1 Solution

Accepted Solutions
Channa
Valued Contributor III

Re: How to create a stacked bar chart with multiple columns on Qlik

it will not work like that bro

 

select 'TopPriority' as PriorityType,
if(SavingMoney='TopPriority',count(SavingMoney)) as TopSaving,
if(FindingJob='TopPriority',count(FindingJob)) as TopFindingJob,
if(Education='TopPriority',count(Education)) as TopEducation,
if(Child='TopPriority',count(Child)) as TopChild
from table

concatenate

select 'SecondPriority',
if(SavingMoney='SecondPriority',count(SavingMoney)) as SecondSaving,
if(FindingJob='SecondPriority',count(FindingJob)) as secondFindingJob,
if(Education='SecondPriority',count(Education)) as secondEducation,
if(Child='SecondPriority',count(Child)) as secondChild
from table

this will generate 5 columns 

use PriorityType as ur Dimension

 

Channa
8 Replies
Channa
Valued Contributor III

Re: How to create a stacked bar chart with multiple columns on Qlik

try build 4 measures and use stacked bar

Channa
Taka4
New Contributor II

Re: How to create a stacked bar chart with multiple columns on Qlik

Thank you for your solution! I am a little confused... If I add count[saving money], count[Finding/Keeping a job], etc as measures, what should I add for dimension?

Channa
Valued Contributor III

Re: How to create a stacked bar chart with multiple columns on Qlik

4 measure for 'TopPriority' as static text in your script

union

4 measure for 'SccondPriority' as static text in your scriot

 

static text column should be ur dimension

 

Channa
Taka4
New Contributor II

Re: How to create a stacked bar chart with multiple columns on Qlik

Sorry I am new to Qlik, and still could not solve this issue... So you meant the dimension should be like

 =Text(Top priority) ∪ Text(Second priority) 

in script? I could not figure out how to add static text in my script and how to do a "union" between these two... Thank you so much for your help.

Channa
Valued Contributor III

Re: How to create a stacked bar chart with multiple columns on Qlik

select 'TopPriority', sum(measure1),sum(measure2),sum(measure3),sum(measure4)

concatenate

select 'SecondPriority', sum(measure1),sum(measure2),sum(measure3),sum(measure4)

 

ur dimension is static text

Channa
Taka4
New Contributor II

Re: How to create a stacked bar chart with multiple columns on Qlik

Thank you so much for taking your time to explain... 

I still cannot understand how to add static text on dimensions. I added Top priority there, but it said "Invalid dimension" as shown below. Also, how do you concatenate two dimensions?

Screen Shot 2019-03-02 at 10.12.19 AM.png

Channa
Valued Contributor III

Re: How to create a stacked bar chart with multiple columns on Qlik

it will not work like that bro

 

select 'TopPriority' as PriorityType,
if(SavingMoney='TopPriority',count(SavingMoney)) as TopSaving,
if(FindingJob='TopPriority',count(FindingJob)) as TopFindingJob,
if(Education='TopPriority',count(Education)) as TopEducation,
if(Child='TopPriority',count(Child)) as TopChild
from table

concatenate

select 'SecondPriority',
if(SavingMoney='SecondPriority',count(SavingMoney)) as SecondSaving,
if(FindingJob='SecondPriority',count(FindingJob)) as secondFindingJob,
if(Education='SecondPriority',count(Education)) as secondEducation,
if(Child='SecondPriority',count(Child)) as secondChild
from table

this will generate 5 columns 

use PriorityType as ur Dimension

 

Channa
Taka4
New Contributor II

Re: How to create a stacked bar chart with multiple columns on Qlik

Thank you so much for your help! That solved my issues!