Count number of male and female in a given range - excel

I have a workbook with about 3000 table rows of student data categorized according to their name, gender (male or female), age and age range (<=13, 14-17 and 18-20). I want to extract the total number of number of male and female that fall within each age range. I've tried using using Countifs() function, but it doesn't seem to recognise the <13 range. How can I achieve this by any means for the purpose of constructing a pivot-chart.
Please, see the workbook at https://1drv.ms/x/s!AghFlVg6p0YpkCRqvKvd4_5gOsNq?e=QPoMWD

Related

Count the number of cells in a dynamic range with a criteria

This is a sample of the data I have:
I'm trying to count the number of kids in a house based on the age values I have in D column. Anybody under the age of 18 is a kid. I want the values in the green box. This is obviously a small sample. The actual data is thousands of rows.
If the number of members per house is accurate, you can use
=IF(A2="","",COUNTIF(INDEX(D:D,ROW()):INDEX(D:D,ROW()+B2-1),"<18"))

Filter excel pivot table by complex combination of several fields

Let's assume I have an excel table with at least 3 columns, "Text1", "Text2" and "Number". Text1 and Text2 obviously contain textual content and Number is a numerical value. I create a pivot table from this table with Text1, Number and Text2 in the rows (in this order). I do already group my results by ranges of Number.
I would like to filter my pivot table so that I only include results, that share a value of Text1 with at least one other entry, while also being the same range of Number and while having a different value for Text2 than the other entry (the one they share Text1 with).
Is this possible? I don't mind adding additional fields to the original data table for calculations if necessary.
Example
Let's say I have a table that contains the fields FirstName, Sex and Age like this:
FirstName Age Sex
Kim 19 Female
Kim 57 Female
Kim 20 Male
Tom 23 Male
I group my ages by steps of 25, so 0-24, 25-49 and so on. In this case I would like to only find all the Kims in the same age range that have a different sex.
Thanks to Ilia's comment, I was able to find a solution. I needed three additional columns in my table:
Concat: The concatenation of my Text1 and Text2 field
Group: A field that calculates the groups of my Number field (using QUOTIENT)
Count: This field uses COUNTIFS to count my fields if there are other matches in the Concat column that have the same value as this has in the Concat column and the same for my Group column.
I am now able to use my Count column as a row in the pivot table (below Text2) and add a label filter to check if the value is greater or equal to 2.

How can I remove non-matching values in two different columns and sort in Excel?

I have several columns of data in my Excel spreadsheet.
Originally, I had two different spreadsheets, as they were generated from reports in a software application.
One of the spreadsheets contains the names of individuals who have had transactions with us in the past year. The other spreadsheet contains the names and the phone numbers. I copied and pasted the columns with the names and phone numbers into my spreadsheet with just the names of people who have purchased something from us in the past year.
My ultimate goal is to extract the names and phone numbers of only the names that have purchased something in the past year.
My column for the past year contains 1,002 names, while my master customer list (with phone numbers) contains over 20,000 individuals. I need the phone numbers of all of the individuals that have purchased something from us in the past year, but I don't want to have to manually go through 1,000 names (and, essentially, 20,000+ to find the match).
If I can achieve my goal without having to use VBA, that would be great. If this is the only route I can take, then I will go that route, but I would like to avoid coding if possible. (This is simply due to time constraints.)
The VLOOKUP function is likely the best solution for you. From the Excel documentation, it:
Looks for a value in the leftmost column of a table, and then returns
a value in the same row from a column you specify. By default, the
table must be sorted in an ascending order.
Note well the implication of that last sentence: the column you're searching in (leftmost column of the lookup table) must be sorted in ascending order for this function to produce the correct results.
Taking a simple example, let's say you have Sheet1 in your Excel workbook with the following information:
A B C
1 Name Transactions Phone
2 Sally 3
3 Alice 5
4 Joe 2
5 Jon 1
You need to add their phone numbers to this sheet, from another workbook. Let's say your phone number information in the other workbook looks like this:
A B
1 Name Phone
2 Alice 2222222
3 Bill 3333333
4 Bob 4444444
5 Jim 5555555
6 Joe 6666666
7 Sally 7777777
8 Sue 8888888
9 Tom 9999999
Take the following steps to add the phone numbers to Sheet1 in the first workbook:
Copy the phone information into a blank sheet in the first workbook. Let's call this Sheet2 for this example.
Make sure the phone information is sorted ascending by the Name column (A), because that's the leftmost column and thus the lookup column.
In cell C2 of Sheet1 (the empty phone cell for Sally), enter: =VLOOKUP(A2, Sheet2!A$2:B$9, 2,FALSE).
Drag-copy this formula down to the remaining cells in the Phone column.
Result:
A B C
1 Name Transactions Phone
2 Sally 3 7777777
3 Alice 5 2222222
4 Joe 2 6666666
5 Jon 1 #N/A
Notes:
The second parameter (Table_array - the lookup data range) should not include the column headings. As you can see, it's Sheet2!A$2:B$9 so it includes the information from rows 2 to 9 in columns A and B.
The last parameter (Range_lookup) should be set to FALSE so you don't pick up the information from the closest match. Note how Jon has no matching phone number record, so his Phone is set to "#N/A" - otherwise he would have been assigned Joe's phone number since that's closest match to Jon.
Parameter documentation:
Lookup_value is the value to be found in the first column of the table, and can be a value, a reference, or a text string.
Table_array is a table of text, numbers, or logical values, in which data is retrieved. Table_array can be a reference to a range or
a range name.
Col_index_num is the column number in Table_array from which the matching value should be returned. The first column of values in
the table is column 1.
Range_lookup is a logical value: to find the closest match in the first column (sorted in ascending order) = TRUE or omitted; find
an exact match = FALSE.

Retrieve multiple results in a data table

I have set up this Excel page with approximately 40 rows and 8 columns to compare the financial benefits of 2 different products based on age.
Once I input an age at the top, the next row will have that age +1 for approximately 40 rows, and then the columns beside it will value my products at the new age in every column.
I want certain information from my 5th column, based on the age that is being inputted (I figured out this part). I have a list of ages that I need to use as inputs and want the information from column 5 for each one of those input ages at the same time. I tried using a data table.
To grab the information from column 5 I use this formula: =INDEX($B$9:$F$49,MATCH(E$55,$B$9:$B$49,),5)
if i understand, the age is in column B, and the needed info in column F ?
Also E55 is the searched Age ?
Then you where near :
try
= INDEX($B$9:$B$49,MATCH(E$55,$B$9:$B$49,),5)

How to SUM parts of a column which have same text value in different column in the same row

I have a column with names and a column with numbers:
FirstName Name Number
John Smith 17
John Smith 26
Peter Smith 116
Peter Smith 25
Franck Black 17
Luke Peterson 17
Luke Peterson 37
Names with same FirstName and Name represent the same person. I need to sum the numbers associated with them. I prefer not to use VBA.
A PivotTable might suit, though I am not quite certain of the layout of your data:
The bold numbers (one of each pair of duplicates) need not be shown as the field does not have to be subtotalled eg:
This can be done by using SUMPRODUCT as well. Update the ranges as you see fit
=SUMPRODUCT(($A$2:$A$7=A2)*($B$2:$B$7=B2)*$C$2:$C$7)
A2:A7 = First name range
B2:B7 = Last Name Range
C2:C7 = Numbers Range
This will find all the names with the same first and last name and sum the numbers in your numbers column
If your data has the names grouped as shown then you can use this formula in D2 copied down to get a total against the last entry for each name
=IF((A2=A3)*(B2=B3),"",SUM(C$2:C2)-SUM(D$1:D1))
See screenshot

Resources