5 Replies Latest reply: Jun 26, 2017 7:12 PM by Marco Wedel

# 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

• ###### Re: Counting the number of instances where two values are given

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

• ###### Re: Counting the number of instances where two values are given

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.

• ###### Re: Counting the number of instances where two values are given

Hi Michael,

see Attachment.

Regards,

Antonio

• ###### Re: Counting the number of instances where two values are given

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

• ###### Re: Counting the number of instances where two values are given

Hi,

other solutions could be:

```-Sum(Victim_Sex=Perp_Sex)
```

or

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

hope this helps

regards

Marco