Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik_here
Contributor II
Contributor II

Calculate distribution (%) based on column values

Hi guys,

My data is organized below and I would like to make a bar graph with the dimension being Company and the graph will show the distribution of gender (Male/Female) for each company. (e.g. For A, it will show two bars, first bar is 40% for Male and second bar is 60% for Female) Is this possible to do it inside set analysis? I don't want to create a separate table from the main one.

CompanyMaleFemale
A2030
B3020
C1012

 

All help and feedbacks are appreciated! Just let me know if you guys need more details.

Labels (2)
1 Solution

Accepted Solutions
dplr-rn
Partner - Master III
Partner - Master III

You can do it 2 ways

1 with the current table structure

Company as dimension and  expressions Sum(Male)/Sum(Male+Female) and Sum(Female)/Sum(Male+Female)

2 this in my opinion is the more flexible option. you transform the table using cross table to

CrossTable (Sex,Count,1)
load * inline [
Company,	Male,	Female
A,	20,	30
B,	30,	20
C,	10,	12

];
CompanySexCount
AMale20
AFemale30
BMale30
BFemale20
CMale10
CFemale12

 

this make the datamodel more flexible

then create bar chart with dimensions Company and Sex

measure Sum(Count)/Sum(total <Company> Count)

View solution in original post

2 Replies
dplr-rn
Partner - Master III
Partner - Master III

You can do it 2 ways

1 with the current table structure

Company as dimension and  expressions Sum(Male)/Sum(Male+Female) and Sum(Female)/Sum(Male+Female)

2 this in my opinion is the more flexible option. you transform the table using cross table to

CrossTable (Sex,Count,1)
load * inline [
Company,	Male,	Female
A,	20,	30
B,	30,	20
C,	10,	12

];
CompanySexCount
AMale20
AFemale30
BMale30
BFemale20
CMale10
CFemale12

 

this make the datamodel more flexible

then create bar chart with dimensions Company and Sex

measure Sum(Count)/Sum(total <Company> Count)