How to exclude data based on other conditions - excel-formula

I'm trying to create a formula based on the following.
A5 = ward (e.g. 14, 15 or 16)
I5 and J5 are providing dates patient transferred offsite and to home
If I5 and J5 are blank then I want to be able to add the fact we still have a patient in this ward, once the date is added to either I5 or J5 I want the 14, 15 or 16 to be excluded.
Based on this formula, I want to be able to show how many patients I have left in 14, 15 and 16 and a total at the end.

this formula will give you how many is left in ward 14 (data from a5 to A13 in my example): =COUNTIFS(A5:A13,14,I5:I13,"",J5:J13,"")
It counts all occurences of 14 in A column, blank in I column and blank in J column. (You can add similar formulas for wards 15 and 16 and add a sum as well.)

Related

Make formula for list of row names independent from entire column and first row

I have the following Excel spreadsheet:
A B C D E F G H
1 Q1 Q2 Q3 Q4 Search criteria: 60 Asset 2
2 Asset 1 15 85 90 70 Asset 3
3 Asset 2 40 80 45 60 Asset 3
4 Asset 3 30 60 55 60 Asset 5
5 Asset 4 12 72 25 15
6 Asset 5 60 48 27 98
7
In Cells A1:E6 I have different assets with their performance from quarter Q1-Q4.
In Column H I list all assets that match the search criteria in Cell G1.
In this case the search criteria is 60 which can be found in the Cells A1:E6 for the Assets 2, 3 and 5.
For creating the list I use the formula from here:
=INDEX(A:A,SMALL(IF($B$2:$E$6=$G$1,ROW($B$2:$E$6)),ROW(1:1)))
All this works fine so far.
Now when I move the Cells A1:E6 in the sheet for example to D9:H14 the array formula keeps only working if it still refers to A:A and ROW(1:1) which might be a problem if the user decides to delete ROW(1:1). Therefore, I tried to modify the formula to:
=INDEX($D$9:$D$14,SMALL(IF($E$10:$H$14=$J$10,ROW($E$10:$H$14)),ROW($D$9:$H$9)))
However, with this modification I get #NUM! error.
Do you have any idea if it is possible to make the array formula independent from A:A and ROW(1:1) so it refers only to the Cells A1:E6 and automatically moves when the those cells are moved?
If you use excel 2013 or later then you can use following formula.
=IFERROR(INDEX($D$10:$D$14,AGGREGATE(15,6,ROW($1:$5)/($E$10:$H$14=$J$10),ROW(1:1))),"")
You can limit A:A to A1:A6 so that it would adjust as necessary when you move it. Your formula should thus be now
=INDEX(A1:A6,SMALL(IF($B$2:$E$6=$G$1,ROW($B$2:$E$6)),ROW(1:1)))
As for ROW(1:1), your top formula should always be ROW(1:1) and when you drag it down, then next formula should have ROW(2:2). When you move your top formula somewhere else and the ROW(1:1) changes to something like ROW(9:9) or anything, change it to ROW(1:1).
Please note that 'moving' your formula is different from 'dragging it down'.
EDIT:
So after you moved your data set, the top formula should now be:
=INDEX($D$9:$D$14,SMALL(IF($E$10:$H$14=$J$10,ROW($E$10:$H$14)),ROW(1:1)))
This is assuming that cell G1 (criteria) is also moved to J10.

How to find number of matching values with an ID?

I have a unique list of IDs of people on two separate sheets. One for initial 'registration data' which is the master data list. In column A is the ID, column B is their town of residence and column C is the date in which the person was added to the list.
I send out sheets to the different towns every month to receive some more data about the new people added to the list, and every month (the same month) they should send it back to me. This received data goes onto a second sheet, with again: column A for person, B for town, and C for month data received.
I need to check how accurate the towns are in getting the data back to me on time. So I need to count the number of forms on the second sheet where the month is the same as the initial month on sheet number one, and the towns match too.
I have tried COUNTIFS with VLOOKUPs but am having no luck. I want to avoid having to make an interim data table as much as possible because I need the process to be slick and automatic.
Could this be done with a SUMPRODUCT?
For example:
Sheet 1 (initial) Sheet 2 (received)
123, TownA, Feb 123, TownA, Feb
124, TownB, Feb 124, TownB, Mar
127, TownB, Mar 127, TownB, Mar
130, TownC, Mar 130, TownC, Mar
220, TownC, Apr (we didn't receive back 220)
OUTPUT SHEET
Feb Mar Apr
TownA 1 0 0
TownB 0 1 0
TownC 0 1 0
As you can see, of the five forms we only received three in the month we were supposed to. I want it in the view above, and don't really want to have to make a new sheet with the IDs to match the months up.
In Sheet3 with Feb in C1, Mar in D1 and Apr in E1 and 123 etc in A2 etc, in B2:
=VLOOKUP(A2,Sheet1!A:B,2,0)
in C2:
=(INDEX(Sheet1!$C:$C,MATCH($A2,Sheet1!$A:$A))=C$1)*(INDEX(Sheet2!$C:$C,MATCH($A2,Sheet2!$A:$A))=C$1)
C2 copied across to E2 and B2:E2 copied down to suit.
Then select A:E and DATA > Subtotal At each change in: (ColumnB), Use function: Sum, Add subtotal to: check Feb, Mar, Apr, Summary below data and OK.
Copy A:E, Paste Special, Values over the top and apply filter. Filter ColumnB, Text Filters, Custom Filter..., contains Tot, OK.
In the first populated cell in ColumnB enter =Bn (where n is the row number immediately above that cell, though not visible) and copy down to suit.
Hide or delete the totals row to suit.

Get user input for month and year to populate cells with dates of that month and year in excel

i want to take two inputs from user Year and month and then populate the cells with the dates of that month and year in excel.
for example:
Enter year:2017
Enter month:Jan
Date
1/1/2017
1/2/2017
1/3/2017
1/4/2017
.
.
.
.
the cells should auto populate when the month and year is entered.
thanks for suggestions in advance.
Without context, it's not clear what you need. Do you want the user to enter the data in dialog boxes or enter the data into two cells? What format will the user be expected to enter the dates in? For example, should January be entered as "Jan", "January", "1" etc.? You probably just need to have 31 formulas set up that reference the input cells, but you need to specify exactly how that input is handled first.
EDIT:
That was meant to be a comment, not an answer, so here is my actual answer:
In cell A1, set up a data validation rule. The rule should be a list with the source given as "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec" or the longer form if you prefer. Now when you try to edit this cell you have the option of selecting from a drop-down list of months.
If you want to limit the year range as well, you can do something similar in cell B1. Just create comma-separated list of valid years in the source field.
Enter the numbers 1 to 31 in cells A3 to A33 then enter this formula in cell B3:
"=DATEVALUE(A3&"-"&$A$1&"-"&$B$1)"
Autofill/copy that down to B33. The DateValue function takes the calculated string (for example "13-Feb-2017") and converts it to a date which you can then format any way you want. Note that this will produce the error "#VALUE!" if either of the input cells are blank or if the choosen month doesn't have 31 days, but you can modify it to your own needs.
Assume this.
Cell b1 tooks input as month, create a name range rng
cell d1 tooks input as year, create a name range yearsamp
column I and J have this, with a formula in j3.
=IF(MOD(yearsamp,4)=0,29,28)
month days
1 31
2 29
3 31
4 30
5 31
6 30
7 31
8 31
9 30
10 31
11 30
12 31
name above cell range as monthdays
use this formula in A2 and fill
=IF(VLOOKUP(mnth,monthdays,mnth,FALSE)>=ROW(A2)-1,DATE(yearsamp,mnth,ROW(A1)),"N/A")
This is another option to achieve this
You can use this formula also.set up as said above.
on first field for 1st date enter this on A2
=DATE(d1,MATCH(b1,I1:I12,0),1)
On A3 write this forula and fill
=IF(ROW(a2)-1<VLOOKUP(mnth,mnthdays,2,FALSE),a2+1,"")
As you have 31 cells with formula it return errors when the month day count are less than 31 but this formula show those as blank without errors.

Excel horizontal list to columns

I am looking to format some data. To make it more easy I use an example with simple numbers.
Sheet 1 ('S1'):
A1 10
A2 14
A3 23
A4 12
A5 64
A6 32
.... etc
It is a long list(vertical) of 600 values
Now I want in Sheet 2('S2'):
To show it as:
S1!A1 S1!A2 S1!A3 S1!A4 S1!A5 S1!A6
S1!A7 S1!A8 S1!A9 S1!A10 S1!A11 S1!A12
S1!A13 S1!A14 S1!A15 S1!A16 S1!A17 S1!A18
References to the cells in the other sheet.
I have tried to transpose them but I cannot find a modifier to set an amount of columns used. i.e. I would get 1 row with all my data. I want only the first 6 in row, next 6 in next row, next 6... etc.
Thanks for any help/feedback given.
Put this in the upper left cell desired:
=INDEX(Sheet1!$A:$A,(ROW(1:1)-1)*6+COLUMN(A:A))
Then copy/drag over 6 columns and down till you finish the list
Sheet1

vlook up for multi combination value

Friend.
I have sheet1 like below
Jan Feb Mar Apr
A 10 15 13 10
B 11 11 15 12
C 12 13 15 14
D 12 10 10 15
In Sheet 2! i have 2 scroll scroll down list in cells made by data validation.fist one is in A1 with the values A, B and C, in A2 cell with the values Jan,Feb,Mar.
What i need on this, if i select A and Jan from scroll down list. i need to show the value as '10' in A3 Cell
I tried VLook up with my limited knowlege but i can provide only one value in Lookup value and array.
Please help.
You have to provide vlookup a number of column to return as variable, which you may get as a return value of match function.
Sheet1 has populated range A1:E5, where first row contains names of months (range A1:E1). Sheet2 has only values in two cells A1 and A2.
You need to find in which column of Sheet1 is a month, that is done by
match(a2, Sheet1!A1:E1, 0)+1
and find the value with VLOOKUP.
The final formula would be
=vlookup(a1, sheet1!a1:e10, match(a2, sheet1!A1:e1, 0)+1, false)
EDIT: The first time I messed Sheet1 and Sheet2.

Resources