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

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"))

Related

Count number of male and female in a given range

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

Weighted average by unique identifier on excel 2013

Assuming I have 10,000 rows with different the unique identifiers such as chairs, tables, sofa etc that are repeated with different combinations of price and quantity,How can I find the weighted average price for the chairs as well as other unique identifiers without manually dividing the sum of prices by the sum of the quantity for chairs?
Example, if the data has chairs where $12,$14,$22 are the prices and 28,13,5 are the quantity of chairs available respectively to the price. Thus, there are 28 chairs available for $12 and so on.
Thanks.
It would be better if we had access to your data, but it seems that using a conditional sumproduct over a conditional sum solves your issue.
Here follows an example:
Assuming:
A = object's name
B = object's quantity
C = object's price
=SUMPRODUCT(--(A1:A10000="Chair"),B1:B10000,C1:C10000)/SUMIF(A1:A10000;"Chair";B1:B10000)
It's not very common to use a "conditional SUMPRODUCT" so I recommend that you read more about it here

Quantifying conditional duration of values in excel

I am trying to analyze blood pressure that is taken every minute, and determine how long the values are within a certain range, consecutively. I have the data set up in excel for the moment. I have color coded the values based on the ranges I would like to quantify. I know that if I do a simple "=countIF) function I can get the total number of times these values meet the criteria. But what I want to do next is quantify for how long the values fall within a specified range, consecutively.
This shows values in columns in excel, where each column is a different patient, and the heat map are the value conditions to help me visualize if certain thresholds occur for longer times than others. But I want to find a way to quanitify this in excel, if possible. Any help would be much appreciated.
The final result I am looking for is to be able to measure how much time each patient sustains a specific category of blood pressure to know if certain ranges are more prolonged than others (e.g. blood pressure is between 120-130 for 30 minutes). So in the spreadsheet above, assuming each cell is a 1-minute bin, for column HU, BP is between 120-130 for 3 minutes (rows 2-4), and again for 16 minutes (rows 6-22). In column HS, blood pressure is above 140 (black) for 7 minutes.
I want to find a workflow to quantify these durations so that I can get a summary of the number of consecutive 1-minute bins (each cell) at a specified range/threshold for each patient (column)
First, I would create another sheet -- let's call it "Thresholds" -- with thresholds of bloodpressures in ascending order in column A.
Put a category number next to each value (in column B)
For example:
0 0
90 1
100 2
105 3
110 4
115 5
120 6
125 7
... etc.
Back in the other sheet, add a new column next to each bloodpressure column. So you
would have a new column HR next to HQ.
Put there a formula that looks up the category for the value in HQ, from sheet "Thresholds".
You can use VLOOKUP for that. For example in row 2:
=VLOOKUP(HQ2, Thresholds!$A$1:$B:$1000, 2)
Then add yet another column, HS it will be.
In there make a running count for same category rows, like this (for row 2, I assume you have used row 1 for column titles):
=IF(HR1<>HR2, 1, HS1+1)
Drag down this formula to the column. This formula checks if this row has a different category of blood pressure than the previous one. If so, it
sets the counter to 1 (it is the first instance in this running series). In the other
case it takes the value of the counter in the previous row and adds 1 to it.
Repeat this for the other columns (inserting 2 new columns next to each).
This will already give you a start for further analysis.

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)

Generating letter by its position in the alphabet

I want a formula that can return the letter of the excel alphabet (27 = AA etc.) of a given number.
The purpose of this is that I have a table that returns values in a spreadsheet. I am summarizing data of climate measurements in cities, this data takes up 4 columns (but the same rows and relative positions in each column, so I29 and J29 contain 2 numbers I need, and then M29 and N29 contain the same data for the next location.
I want to create a summary table that looks like the below
City Rainfall Average Sunshine Average
City A =I29 =J29
City B =M29 =N29
City C etc.
my problem is that i go up to a few hundred cities, and i want to be able to populate the cells automatically/fill down. I know what row the data is in but need to generate the column letters using the formula requested above, so I can use a concatenate to create the cell reference.
You can use the ADDRESS function.
For example, =ADDRESS(29,27) will return the string "$AA$29".
However, honestly in your situation I would use the OFFSET function, combined with ROW(). To illustrate, let's say your table starts with a header row on row 50 and data starts on row 51. The data for a given city would start (ROW() - 51) * 4 columns to the right of I29. So:
A B C
50 City Rainfall Average Sunshine Average
51 City A =OFFSET($I$29,0,(ROW()-51)*4) =OFFSET($I$29,0,(ROW()-51)*4+1)
52 City B =OFFSET($I$29,0,(ROW()-51)*4) =OFFSET($I$29,0,(ROW()-51)*4+1)
53 City C etc.
Of course, you have to be careful if you want to move these cells around; you'll have to change the 51.

Resources