Quantifying conditional duration of values in excel - 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.

Related

Find row when Cumulative sum reaches certain value with condition

I have a table with 3 columns Date, Item and Number. Each row indicates how many items of each Item was received on that date. I am trying to find the date on which cumulative sum reaches 100 or more in that month. Each month will have a target for each item which will be saved in another sheet but for simplicity we can assume that its a fixed number of 100.
Example Data:
Date Item Number
1/2/2018 A 10
2/2/2018 B 10
2/2/2018 A 15
5/2/2018 C 25
6/2/2018 A 50
7/2/2018 B 10
7/2/2018 C 10
8/2/2018 A 25
9/2/2018 A 20
I am looking for the formula which should act on the data similar to above and give the result as 8/2/2018 which is the date on which the cumulative sum for Item A reached 100.
Each month will have different target number, and will have different number of entries.
I have tried using SUMIF and adding a additional column etc but this data is just part of a big data and each item limit is saved in a different sheet etc which is not easy to merge. Thanks in advance for help.
In Excel only, you can use Offset to develop an array of items and numbers containing 1,2,3...9 rows and then SUMIF to add each of them up. Then use Match to find the first one =100 and Index to find the matching date (in F2):
=INDEX(A2:A10,MATCH(100,SUMIF(OFFSET(B2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)),"A",OFFSET(C2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1))),0))
Must be entered as an array formula using CtrlShiftEnter.
EDIT
To find the first sum which is >=100 (in G2):
=INDEX(A2:A10,MATCH(TRUE,SUMIF(OFFSET(B2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)),"A",OFFSET(C2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)))>=100,0))
Sum which reaches exactly 100
Sum which does not reach exactly 100 (the number in row 9 has been changed to 24):

How to sum the bottom value of a column that changes size?

So I'm tracking some investments in excel and the columns of interest are the total value of investments, the value for each investment, date. I have a formula for the net total to the side and I'm using this to manually type the net total into the column. I'm also using this data to create graphs of value vs date.
How can I change this formula so it will always just add up the final values for the total of each investments? I dont want to have to manually fudge the formula everytime I update the tables.
I want to do this because the table is a bit busy due to the data needed for the graphs, it'd be nice just to have the net total by the side and highlighted.
net total date 1 2 3
111 13/01/18 100 10 1 Net total: `Sum(c2, d2, e2)`
121 14/01/18 100 20 1
So I want the net total to just sum the bottom values for columns titled 1, 2, 3. I want it to be dynamic so i can then just type in the net total into the correct column and i can update all the graphs. But also want the net total to be on the side for easy viewing too instead of it getting lost in the raw data
there is a trick using "lookup()":
search(999999;A:A) returns value equals to 999999 or last value if 999999 is greater than every values. So your formula will be:
Net total: "lookup(999999999;C:C)+lookup(999999999;D:D)+lookup(999999999;E:E)"
(assuming none of the values is greatrer than 999999999)
Will the final value from each column always be the same row? If so then this formula will sum the last row in columns B, C and D by finding the last number in column B
=SUM(INDEX(B:D,MATCH(99^99,B:B),0))

Excel: count the number of cells in a column until their sum is greater than a set value

I have a list of consecutive events in one column and their durations in the adjacent column. I want to count the number of times a particular event occurred in a certain length of time.
For example:
Col Event Duration
1-- Contr 8
2-- Relax 5
3-- Contr 12
4-- Relax 6
5-- Contr 10
6-- Relax 5
In this example I want excel to start from row 6 and go backwards, summing durations until the value is over 30 and return the number of times Contr occured over that time period. Here the answer is 2.
Here's a link to an example spreadsheet with more realistic values: https://1drv.ms/x/s!AiOl_zwCwrAmgcgQqCPaOY5WzMZTGQ
(The threshold value would be 900 instead of 30.)
Thanks. Hope I asked the question right.
I would have to use a helper column to work out the totals under the current row. I don't mind if the sum including the current row is 30 or more, as long as the sum under it is less than 30.
So in D2:-
=SUM(C3:C$100)
Then it's just a countifs:-
=COUNTIFS(B2:B100,"Contr",D2:D100,"<"&30)

Excel formula for multiple conditions and worksheets

The aim
I am try to create a formula which will allow specific information from 90 different worksheets, with an example of one such worksheet being below. Each work sheet represents data from a participant.
I want the data from the 90 work sheets to be summarised into the worksheet below.
The problem
The problem is that I need to create a formula that takes counterbalancing into account.
So in cell A3 of the second image I would to record the number of times the value 1 and 3 appears in column I of the first image.
The conditions
However, I would only like the numbers in column I to count if:
a) in column M of image 1 there is a value of 1
and
b) when the number in Column L is 1 and Column K is 1 or 4 OR when the number in Column L is 2 and the number in Column K is 3 or 4.
My attempt
=SUM('[All_memories_301-389_improved.xlsx]Sirma 301:387Yanxin'!$M$2,1*(IF('[All_memories_301-389_improved.xlsx]Sirma 301:387Yanxin'!$L$2,1*(IF('[All_memories_301-389_improved.xlsx]Sirma 301:387Yanxin'!$K$2:$K$41,1,4*(IF('[All_memories_301-389_improved.xlsx]Sirma 301:387Yanxin'!$I$2:$I$54,1,3)))))))
This did not work however and I have spent a long time on this and made changes but I still can't seem to get it to work.
Extra information:
In column I I want to count all the occurrences of 1 and 3 provided the specified conditions are met. The rows are not important, but rather, the column I information for each of the 90 spreadsheets.
New attempt with formula:
=COUNTIFS('[All_memories_301-389_improved.xlsx]381Christie'!$M$2, 1, '[All_memories_301-389_improved.xlsx]381Christie'!$L$2, 1, '[All_memories_301-389_improved.xlsx]381Christie'!$K$2:$K$23, AND(1,4), '[All_memories_301-389_improved.xlsx]381Christie'!$I$2:$I$23, AND(1,3))

Excel count unique occurrences of a text entry based on a status contained in a seperate column

Alright, this is driving me insane...
I have a section of data in a spreadsheet that looks like this:
Column A Column B Column C
lksdf-46-we-32 Fire 1
lksdf-46-we-32 Fire 2
lksdf-46-we-32 Fire 3
lksdf-46-we-32 Fire 4
wgw3f-18-bw-11 Ice 1
wgw3f-18-bw-11 Ice 2
wgw3f-18-bw-11 Ice 3
wgw3f-18-bw-11 Ice 4
possf-12-he-91 Fire 1
possf-12-he-91 Fire 2
possf-12-he-91 Fire 3
possf-12-he-91 Fire 4
oiwen-20-lw-93 Water 1
oiwen-20-lw-93 Water 2
oiwen-20-lw-93 Water 3
oiwen-20-lw-93 Water 4
In another spreadsheet, named 'Variables', I have a lookup category that looks something like this:
Column A
Fire
Water
I need to find the number of distinct entries in column A of the raw data sheet where column B matches any entry in column A of the Variables sheet. What I'm looking for is an excel formula, but everything I've tried either returns duplicates (as a starting point) or returns 0. Also, could you please explain in detail how the query works in excel? I'm a fairly experienced programmer, but I'm having a heck of a time wrapping my head around these functions in excel that I've been tasked to finish by the end of the day.
Try this "array formula" somewhere in the raw data sheet
=SUM(IF(FREQUENCY(IF(ISNUMBER(MATCH(B2:B100,Variables!A:A,0)),IF(A2:A100<>"",MATCH(A2:A100,A2:A100,0))),ROW(A2:A100)-ROW(A2)+1),1))
confirmed with CTRL+SHIFT+ENTER
The formula uses FREQUENCY function, with the "bins" being the row numbers, and counts bins that have 1 or more entry. Entries are only made when the column B item matches Variables column A.....and the second MATCH function ensures that the same row number (the first match) is entered for each repeated item in column A, which guarantees that duplicates are not counted
This formula looks at 100 rows of data in raw data sheet, increase as required but note that formula is very "expensive" so may prove impractical with very large datasets

Resources