Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Calculating %Female out of Total

Hello,

I am trying to calculate % of females out of my total population. My excel file has columns like Name, ID,....... Gender, etc. and each ID has a gender (male or female).

I tried applying the following formula but it's not working:-

Sum([Gender]={'Female'}) / Sum([Gender]={'Female'}) + Sum([Gender]={'Male'})

Thoughts?

Thanks!

Ankit

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: Calculating %Female out of Total

Try this:

Count(DISTINCT {<Gender = {'Female'}>}ID)/Count(DISTINCT ID)

UPDATE: Added DISTINCT in case you have duplicate IDs and you don't want to count them twice

9 Replies
MVP
MVP

Re: Calculating %Female out of Total

Try this:

Count(DISTINCT {<Gender = {'Female'}>}ID)/Count(DISTINCT ID)

UPDATE: Added DISTINCT in case you have duplicate IDs and you don't want to count them twice

Not applicable

Re: Calculating %Female out of Total

Hi Sunny,

Thanks for your quick response. Appreciate it!

So, I am trying to show the percentage in a Gauge chart, and the formula still doesn't seem to be working. Here's a snapshot of what I am seeing. I know my data and it should show 49.30% but it shows 0.50%

Count(DISTINCT {<Gender = {'Female'}>}ID)/Count(DISTINCT ID)

Am I doing something wrong?

Thank you!

Ankit

Employee
Employee

Re: Calculating %Female out of Total

Count([Gender]={'Female'} PersonField) / (Count([Gender]={'Female'} PersonField) + Count([Gender]={'Male'} PersonField))


*/ precedes +-

MVP
MVP

Re: Calculating %Female out of Total

But is the syntax correct Clever‌? I have never seen a syntax like that before.

Employee
Employee

Re: Calculating %Female out of Total

sorry, sunny, I´ve didn´t checked this, only noted /- precedence

Count({<[Gender]={'Female'}.>} PersonField) / (Count({<[Gender]={'Female'}>}PersonField) + Count({<[Gender]={'Male'}>}PersonField))

MVP
MVP

Re: Calculating %Female out of Total

No sorry needed my friend. I was just wondering if this syntax actually works

MVP
MVP

Re: Calculating %Female out of Total

Are there places where Gender is not filled in?

May be try this:

Count(DISTINCT {<Gender = {'Female'}>}ID)/Count(DISTINCT {<Gender = {'Female', 'Male'}>}ID)

Not applicable

Re: Calculating %Female out of Total

Silly me. This formula is perfect. I just added *100 at the end to make it a percentage to make it work. The needle does show the correct female representation now.

Thanks a lot!

Ankit

Not applicable

Re: Calculating %Female out of Total

Thanks for pitching in, Clever! Appreciate it.

Cheers!
Ankit

Community Browser