Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Taka4
Contributor II
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
Labels (2)
1 Solution

Accepted Solutions
Channa
Specialist III
Specialist III

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

View solution in original post

8 Replies
Channa
Specialist III
Specialist III

try build 4 measures and use stacked bar

Channa
Taka4
Contributor II
Contributor II
Author

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
Specialist III
Specialist III

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
Contributor II
Contributor II
Author

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
Specialist III
Specialist III

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
Contributor II
Contributor II
Author

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
Specialist III
Specialist III

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
Contributor II
Contributor II
Author

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