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: 
sqlpuzzle
Contributor III
Contributor III

Unexpected Result from an Expression

Hi,

I am trying to calculate the percentage for a Dimension (M/F). When the Gender Dimension is selected in the Filter the result from the calculation is wrong (weird). Obviously my expression is wrong.

= Count({$< Gender = {"M"}>}  SalesOrderNumber)/ Count(  SalesOrderNumber)

gender_percentage_expression.PNG

When the Female Gender is selected the % Male calculation is expected to be zero. That is what I am expecting.

How to get that?

Attaching the file.

Thanks

5 Replies
dplr-rn
Partner - Master III
Partner - Master III

ignore the Gender dimension in the denominator. if you dont you are dividing male count/female count

Count({$< Gender = {'M'}>}  SalesOrderNumber)/ Count( {$< Gender = >} SalesOrderNumber)

Count({$< Gender = {'F'}>}  SalesOrderNumber)/ Count( {$< Gender = >} SalesOrderNumber)

sqlpuzzle
Contributor III
Contributor III
Author

Why the filter is not getting rid of the filtered dimension?

If I select M in the filter, I was thinking the Female records will be filtered out and the percentage will either dissappear or become zero.

dplr-rn
Partner - Master III
Partner - Master III

With old or new?. New one I shared ignored gender selection for the denominator

sunny_talwar

May be you need these expressions

= Count({$< Gender *= {"M"}>}  SalesOrderNumber)/ Count({<Gender>}SalesOrderNumber)

= Count({$< Gender *= {"F"}>}  SalesOrderNumber)/ Count({<Gender>}SalesOrderNumber)


Capture.PNG

Jesh19
Creator II
Creator II

You can try something like this:

= Count({$< Gender = {"M"}>}  SalesOrderNumber)/ Count(TOTAL SalesOrderNumber)

= Count({$< Gender = {"F"}>}  SalesOrderNumber)/ Count(TOTAL SalesOrderNumber)