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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
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

1 Solution

Accepted Solutions
sunny_talwar

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

View solution in original post

10 Replies
sunny_talwar

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
Author

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

Clever_Anjos
Employee
Employee

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


*/ precedes +-

sunny_talwar

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

Clever_Anjos
Employee
Employee

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

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

sunny_talwar

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

sunny_talwar

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
Author

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
Author

Thanks for pitching in, Clever! Appreciate it.

Cheers!
Ankit