Countif not counting

EvonS

Board Regular
Joined
Jun 1, 2016
Messages
111
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Ok so let me start off by saying that I know that this is a common problem but none of the common solutions I've tried are working. I will do my best to describe the problem and I am willing to email the spreadsheet to anyone who thinks that they would be able to help.

About the Spreadsheet
'Data Fields' sheet tracks information about individual crisis situations that I review at work. For example:

Situation #Risk FactorsStudy FlagAge Ranges
DE-2018-1Gangs - Gang AssociationHomelessness12 - 17
Gangs - Threatened by GangRisk of Losing Housing30 - 39
Suicide - Current Suicide RiskRecent Escalation0 - 5

<tbody>
</tbody>

There are over 200 of these types of entries and in my deep data analysis I am tracking what study flags and age ranges are associated with with risk factors that I choose. I do this analysis on my 'Deep Analysis' Sheet that is set up like this:

ABCD
1CHOOSE A RISK FACTOR
2<Risk Factor User Selects>#DE-2018-1DE-2018-2
3RISK FACTORS
4Alcohol Use - Alcohol use in the home610
5Suicide - Person current suicide risk700
6Suicide - Person previous suicide risk911
7Parenting - Parent child conflict1001

<tbody>
</tbody>

The formula I use in C2 is all the way over to HB100 is this:

Code:
=IF(COUNTIF(INDIRECT("'Data Fields'!$N" & C$3 & ":N" & C$3+15), $A$2)+COUNTIF(INDIRECT("'Data Fields'!$N" & C$3 & ":N" & C$3+15), $A4)=2, 1, 0)

The cell references change according to the cell. The formula basically produces a 1 or 0 depending on if it finds the risk factor in A2 as well as a risk factor found in A4 on. The formula in column B just adds all the 1s and 0s up for me. This formula actually works for me.

The Problem
Risk factors are divided in to several categories. I would like to calculate associations based on these categories. For example: Suicide is a category with several risk factors in it. The formula above only compares individual risk factors (Suicide - Person previous suicide risk vs Suicide). My solution is this formula that uses a wild card:

Code:
=IF(COUNTIF(INDIRECT("'Data Fields'!$N" & C$3 & ":N" & C$3+15), [B]"*"&$A$2&"*"[/B])+COUNTIF(INDIRECT("'Data Fields'!$N" & C$3 & ":N" & C$3+15), $A4)=2, 1, 0)

Where A2 will contain just the risk category (i.e. Suicide). The issue is that the calculations don't add up correctly compared to when I do it manually.

I really hope all this make sense and I'm completely at a loss around what to try. All the entries in the spreadsheet entered by a drop down menu and all references to the risk factors draw from the same drop down list. I did this to eliminate the possibility of any user errors like extra spaces. I've recalculated the sheet several times and double checked my formulas but I just can't seem to figure this out. Your help would really be appreciated.

Sincerely,


Evon
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top