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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Counting the number of instances where two values are given

I am looking through a public data set which has the sex of both victims and perpetrators

I am wanting to show the Count where both the victim and the perpetrator are the same

e.g The count where Victim and the Perpetrator are both "Male"

The variables are Victim_Sex and Perp_Sex


Any help would be appreciated

5 Replies
Kushal_Chawda

=count({<Victim_Sex ={'Male'},Perp_Sex={'Male'}>} ID)

henrikalmen
Specialist II
Specialist II

It can be done in different ways, it depends on where and how you want to use it. But to display the figure in a text box you could do something like this. I'm using field name [case_id] as key, you should use whatever key you have in your data.

  = count({$<Victim_Sex={"Male"}, Perp_Sex={"Male"}>}distinct [case_id])

That expression uses "set expression" syntax. Another way to do it could be:

  = sum(if(Victim_Sex='Male' and Perp_Sex='Male', 1, 0))

Both examples should give you the number of cases where both the victim and the perpetrator are male.

antoniotiman
Master III
Master III

Hi Michael,

see Attachment.

Regards,

Antonio

balabhaskarqlik

= sum(if(Victim_Sex=Perp_Sex, 1, 0))

MarcoWedel

Hi,

other solutions could be:

-Sum(Victim_Sex=Perp_Sex)

or

Count({$<CaseID={"=Victim_Sex=Perp_Sex"}>} CaseID)

hope this helps

regards

Marco