How can I refer to two different columns in a COUNTIF function? - excel

I have a sheet that looks something like this.
A | B | C
1 Age | how often | occupation
2 21 | I don't | student
3 22 |x times a week| photographer
4 23 | etc | student
5 22 | etc | builder
6 21 | etc | car mechanic
7 20 | I don't | student
I want to track various things, such as the amount of times a student said "I don't".
I'm using google spread sheets at the moment.
How in google spread sheets can I calculate this?
At the moment this is the query I'm using to try to calculate this.
=ARRAYFORMULA(sum((B2:B7="I don't") * (C2:C7="student")))
All results are coming up as zero - cannot seem to get a result.
If anyone could help it would be much appreciated.
Have also tried below with no luck.
=SUM(IF(B2:B7="I don't",IF(C2:C7="student",1,0)))
Any help would be greatly appreciated. Thank you very much.

In google-spreadsheets, as well as in Excel, you can use the COUNTIFS() (Google, Excel) function:
=COUNTIFS(B2:B7, "I don't", C2:C7, "student")

In a google spreadsheet you can also use SUMPRODUCT()
=sumproduct(B2:B7="I don't", C2:C7="student")

You have a few options to present this information, I'll talk to countifs and pivots:
To count the amount of occurrences a text has appeared in a range of cells you'll use a formula like =COUNTIFS(B2:B7, "I don't", C2:C7, "student") however, if you're looking to see how many the string "I don't" appears, ie.. "I don't know" or "I don't care for your formula" enter in as an array selecting crtl + Shift + Enter. How to Count the Occurrences of a Text String
But. For your case, which I'm guessing is interpreting the data and drawing comparisons, such as counting students vs builders, age vs occurrences, you're better off using a pivot table. This will pull together all the information and provide an automatic sum or count on the criteria set, quickly drawing comparisons. Google has a great how to guide you can refer off for google sheets Google Pivot Table

Related

How to resolve Excel IF AND question query formula

Need help with a Excel formula.
I have two sets of data in two tables, with the same number of columns and rows.
One table has data for male, the other one for female.
Each table has a common definer (age). All the other data are different. All data are in numbers. Some are negative.
I aim to use a single cell to get a result coefficient used by a specific equation, and I need to channel the input data by two criteria. One is gender, the other one is age. I am trying the IF AND formula, but it is not working.
Here is an example.
age (D2) coefficient (D2-D4)
Table Female.
18-30 yrs 25
30-60 yrs 35
60-70 yrs 41
So here is the data to process:
D1 F
D2 29
D3 115
(MEANING Gender - female; age 29; weight 115 pounds)
I was trying the IF AND formula
=IF(AND(D1="F";D2>17;D2<30);(D3+H2);IF(AND(D2>=30;D2<60);(D3+H4)))
Now, this works fine when I only calculate the female data, but I can't seem the find the way to include the formula to choose from the MALE table, if the subject is male ("M").
Any help or clues on how to resolve this?
Welcome to stackoverflow. It would be easy to help you if you paste a screenshot of your table etc as it would make us understand your problem clearly.
Anyway, two solution advice from me:
1- you can use nested if operators but not like yours. Before expressing conditions with and operator, add another if to start processing data related to females. Like this: =IF(D1="F";IF(AND(D2>17;D2<30);(D3+H2);IF(AND(D2>=30;D2<60);(D3+H4))).
After processing females, add the same formula strings this time for males. This will solve your puzzle I guess.
2- my second advice would be creating a user-defined function. I often create a user-defined function if my formula gets too long and become hard to read. I strongly recommend you to search for this as it will make you better-understand the logics in excel functions and make you equipped against your puzzles in future.

How do I build an Excel function to find duplicates in a column, based on other criteria in other columns?

Basically I'm trying to figure out if the Client column repeats, but based on the following criteria.
Dates have to be different
Product is the same
Ticker is the same
Clients are obviously the same as well
Dates
Product
Ticker
CLient
Yes?
13-June
Computer
XYZ
Greg
Y
14-June
Computer
XYZ
Greg
Y
14-June
Computer
XYZ
Sally
15-June
Computer
ABC
Sally
Y
16-June
Rocket
ABC
Sally
17-June
Computer
ABC
Sally
Y
Ideally, the Yes? column should contain my formula. I think I'm halfway there using counties,but I keep running into problems with the product bit.
Thanks everyone.
If you have the newest version of Excel, you can use FILTER.
For example:
=IF(COUNTA(UNIQUE(
FILTER($I$1:$L$6, $J$1:$J$6&$K$1:$K$6&$L$1:$L$6=J1&K1&L1)))>COUNTA(I1:L1),
"Y","")
if you will not use the "Y" result elsewhere in your file, I mean, if your aim is just to spot the duplicate values; just concat the fields Product, Ticker and Client in another column and apply conditional formatting to highlight duplicate values.

NetSuite Saved Search - Display Total/Calculate Percent when using Grouping

When using the summary function "Group" in Saved Searches (SS), is it possible to show the total count inline or even use it inline? For example, I have a SS that counts the number of cases closed in a certain date range and it groups by the assigned employee and the total is listed at the bottom, as per usual. However, when trying to calculate the percent of the total each employee closed, they all show as 100%.
Here is a picture of the results and I have also added the formulas I am currently using. Here is what it looks like when I'm editing the search. The right most columns were my attempt at getting the total inline.
I'm fairly certain this is because I am grouping by the employees (or else there would be almost 3k lines in the report), but I don't think there is a better way to solve that problem other than by grouping by the employee.
We have tried doing an actual report in NetSuite (as opposed to saved search), however, the report times out quickly and we are hoping for a quicker solution. We also considered a KPI scorecard, but the issue would be that we would need to make a SS for each employee which isn't a good long-term solution due to team changes.
Is there a way of calculating the percent of the total when using grouping? Sorry for the long post, I was trying to be as descriptive as possible. The goal is to see how much (percent wise) each employee contributed to the total cases closed.
Take your SUM column that counts the closed cases.
duplicate it but add the function % of total
So
| Field | Summary Type | Function | Formula |
| ----- | ------------ | -------- | ---------------------------------------------------- |
|Formula Numeric | Sum | | Case When {status} like 'Closed%' then 1 else 0 End |
|Formula Numeric | Sum | % of Total | Case When {status} like 'Closed%' then 1 else 0 End |

Use SUMIF with transformed text to number

So I have a monthly budget in Excel that I'm using to keep track of making sure all of my recurring bills get paid on time.
Let's assume I have a table formatted like this:
Bill | Due Date | Amount Projected | Actual Amount | Diff
Mortgage | 1st | $1,500 | $1,510 | -$10
Water Bill | 13th | $30 | $25.80 | $4.20
I get paid on the 1st and the 15th, and I'm trying to get two rows that give a sum of all of the bills that are due within the first paycheck, and a sum of those that are due after.
So I'm trying to use the SUMIF function, however because the DUE DATE column is text and not date so that I get the 1st, 2nd, etc, I'm not sure how to run a comparison on this.
So I have the formula to get rid of the th, nd, etc as:
=LEFT(B2, LEN(B2)-2)
If it didn't have the th, or nd, the SUMIF function would look like this:
=SUMIF(C2:C3, "> 15", B2:B3)
But I just can't figure out how to combine the two formula. Is there any special character that runs the transform on the cell where I can pass that into the formula, without having an intermediate cell somewhere to just hold the 1, or 13 for the date due?
I know there are other ways to do this like just sorting the columns by due date and then only selecting that range, but I'd like to not have to manually change a bunch of other "reporting" columns every time I add or remove a bill.
Thanks for any help in advance.
=SUMPRODUCT((left(B2:B3,len(B2:B3)-2)<15)*C2:C3)
SUMPRODUCT performs array like operations. As such avoid using full column reference such as B:B.

Excel complex formula example

So I would greatly appreciate your help I'm having quite a struggle. What I need currently is listed below. To begin I have a data set with many individuals and information. There are a few columns that I'm interested in.
Table 1:
So each Individual is either labeled as Free, Arc 1, Arc 2 or Arc 3. Each individual also has a number of people associated with it and lastly a cost.
Individual | # of people | Cost | Type | Compliant with Costs?
A |3 |45 |Free |Yes/No?
B |2 |57 |Arc 2 |
Table 2:
I then have a table below that is broken out. Free can have 1 2 or 3 individuals and cost can be between 20 - 30 dollars for 1 30-40 for 2 and 40-50 for 3.
|Free |Arc 1 |Arc2 | Arc 3
# of people | Cost | Cost | Cost | Cost
1 |20-30 |30-40 | 60-70| 90-100
2 |30-40 |40-50 | 70-80| 100-110
3 |40-50 |60-70 | 80-90| 110-120
So i want to take the Individual column noted above and say if Individual A1 is in Free and has 3 individuals is their cost between 40-50 dollars, if so yes, if not no.
I know this will use some if formulas probably many, I tried Index(match()) and such too but couldn't figure it out if you could help that would be greatly appreciated.
Below is an example of a sample Excel file, it looks easy with just two individuals but there are hundreds so I'm hoping there is an easy formula. Again any help is greatly appreciated.
Excel Screenshot Link (Same as example above)
If you change your reference table as follows, you can use a sumifs easily to pull the min and the max and see if your cost is in between
# Type Min Max
1 Free 20 30
1 Arc 1 60 70
2 Free 30 40
I agree that the best way would be to restructure your reference table, but if you'd like to know how to get your answer as is, you can use a combination of =INDEX(MATCH(),MATCH()),=LEFT() and =MID() to get your answer, as in the following example:
The formula in E2 is:
=IF(AND(C2>= (LEFT(INDEX($I$1:$M$5,MATCH(B2,$I$1:$I$5,0),MATCH(D2,$I$1:$M$1,0)),FIND("-",INDEX($I$1:$M$5,MATCH(B2,$I$1:$I$5,0),MATCH(D2,$I$1:$M$1,0)))-1)*1), C2<=MID(INDEX($I$1:$M$5,MATCH(B2,$I$1:$I$5,0),MATCH(D2,$I$1:$M$1,0)),FIND("-",INDEX($I$1:$M$5,MATCH(B2,$I$1:$I$5,0),MATCH(D2,$I$1:$M$1,0)))+1,256)*1),"Yes","No")

Resources