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: 
Not applicable

Percentage of Gender

Hi,

Having some issues with a dimensionless straight table; sure its something easy.

My Data has the following columns

CustomerID, Gender

1111, Male

2222, Male

3333, Female

How do I properly calculate the percentage of Male customer ID's? I seem to be able to calculate it fine but when selections are made the percentage does not make sense.

=(count(distinct{$<Gender={'Male'}>}  CustomerID))

/

count( DISTINCT CustomerID)

This gives 52% with no selections. When I choose Male in a Filter box it shows 100%

BUT when I choose Female in a list box it shows 132%

What am I doing incorrect?

1 Solution

Accepted Solutions
MarcoWedel

Hi,

the set expression {$<Gender={'Male'}>} lets your count of male customers disregard the gender selection, while count( DISTINCT CustomerID) only counts the selected female customers.


so possible solution could be:


count(distinct{$*1<Gender={'Male'}>}  CustomerID)/count( DISTINCT CustomerID)


or


count(distinct{$<CustomerID=p({$<Gender={'Male'}>} CustomerID)>}  CustomerID)/count( DISTINCT CustomerID)

QlikCommunity_Thread_163605_Pic1.JPG

QlikCommunity_Thread_163605_Pic2.JPG

QlikCommunity_Thread_163605_Pic3.JPG

QlikCommunity_Thread_163605_Pic4.JPG

hope this helps

regards

Marco

View solution in original post

9 Replies
robert_mika
Master III
Master III

When you choose Male the Female will be filtered out so for each ID 1111,2222 there is only one Male so is 100%

What do you expect when choosing Female with your current expression(Male).

You can use {1}

=count({1<Gender={'Male'}>}  CustomerID)/count({1} Gender)

To disregard all selections.

Not applicable
Author

When you filter Female your expression perfom the calculation Male / Female.

If you want a single expression to calculate percentage dinamically based on Gender selection try this:

Count({<Gender={"$(=GetFieldSelections(Gender))"}>}DISTINCT Customer) / Count({1}DISTINCT Customer)

Not applicable
Author

When you perform a selection the sub set formed in numerator is always releated to the total Customer count.

Example: selections: Gender = Male, City = New York   

Calculation: Male in New York / Total Customers

Not applicable
Author

if I choose female then the

Female percent should be 100%

=(count(distinct{$<Gender={'Female'}>}  CustomerID))

/

count( DISTINCT CustomerID)

male percent should be 0%

=(count(distinct{$<Gender={'Male'}>}  CustomerID))

/

count( DISTINCT CustomerID)

OR

even if the percentages were a percentage of the total count.

No selections = M 50% F 50%

Select F = M 0% F50%

Select New York - M 0% F 35%

Not applicable
Author

Hi - i tried your expression but it returns '-'

avinashelite

Hi Stuart,

can you please share your app? let me check if its a data issue?

mohammadkhatimi
Partner - Specialist
Partner - Specialist

Hi Stuart...

Please post a sample data

Regards,

Mohammad

MarcoWedel

Hi,

the set expression {$<Gender={'Male'}>} lets your count of male customers disregard the gender selection, while count( DISTINCT CustomerID) only counts the selected female customers.


so possible solution could be:


count(distinct{$*1<Gender={'Male'}>}  CustomerID)/count( DISTINCT CustomerID)


or


count(distinct{$<CustomerID=p({$<Gender={'Male'}>} CustomerID)>}  CustomerID)/count( DISTINCT CustomerID)

QlikCommunity_Thread_163605_Pic1.JPG

QlikCommunity_Thread_163605_Pic2.JPG

QlikCommunity_Thread_163605_Pic3.JPG

QlikCommunity_Thread_163605_Pic4.JPG

hope this helps

regards

Marco

Not applicable
Author

Thanks Marco,

And is it possible to have another calculation where essentially the percentage decreases the more selections ones makes

Choose Male = 50%

Choose Age 25-35 = 20%

Choose Country America = 3%