Records and Rows If Statement Question / Help :)

colerainescotty

New Member
Joined
Feb 25, 2009
Messages
10
Hi folks, I have a simple excel spreadsheet that I am creating to get better at Excel and formulas for my IT course. I have a spreadsheet with some dummy data related to hospital procedures.

At the moment there are 6 doctors who carry out a procedure. The doctors in theory have to be audited and a report sheet produced. At the moment all of the data in a row relates to a particular doctor. There are various pieces of data I wish to collate for a particular doctor.

Firstly if possible I would like to be able to (for the report) say "Find all rows with Dr. A and calculate total dose of Drug A given to patients"


Here is an example of what I am trying to achieve

Excel Sheet

A B C D
1 Doctor Drug Dose
2 Dr. A 1mg
3 Dr. B 2mg
4 Dr. A 4mg

Is there a formula for me to be able to say in another "reporting" sheet (if row contains "Dr A" then total "drug dose")

If you need anymore information please do not hesitate to reply and I will be happy to answer.

Thanks so much in advance and I may have more questions soon :)
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi,

If you put "mg" in the header rather than within the cells, you can do simply this:


Excel 2010
AB
1DoctorDrug Dose mg
2Dr. A1
3Dr. B2
4Dr. A4
Sheet2



Excel 2010
AB
1DoctorTotal Drug Dose mg
2Dr. A5
3Dr. B2
reporting
Cell Formulas
RangeFormula
B2=SUMIF(Sheet2!A$2:A$4,A2,Sheet2!B$2:B$4)

reporting sheet B2 formula copied down.
 
Upvote 0
Hi Thanks for this. This is a good solution if I know where the data is on Sheet 2. However say that there are around 8 records input daily with different doctors. At the end of the month for the report is there a way to automatically do this. E.g for the excel sheet to go and find the amount of dosage total for "Dr. A", then "Dr. B" etc without someone having to manually input and select data?

If there are 100 records or so per month this would make the reporting easier. There are more things I need to do but If I could crack this one I would be flying :)

I am beginning to wonder if a database would be better for this project?

Hope to hear from you soon and thanks for the help
 
Upvote 0
I'm not sure I understand what you mean.

Are you saying you don't know where the data is, in Sheet 2, meaning you don't know what Column or what Rows?

Or, are you saying the number of rows keeps growing?

If it's the latter, you can extend the range in the formula to beyond what you anticipate you need, like:

=SUMIF(Sheet2!A$2:A$400,A2,Sheet2!B$2:B$400)
 
Last edited:
Upvote 0
Hi sorry yes the list will keep growing and there may be different doctors as the list grows. But if I want to report for only certain doctors individually say Dr. A, is there a way to get it to automatically obtain some of the other data in the row if the row relates to Dr A for example. So say I wanted to know the total dose given by Dr.A is there a way to get this from the whole set of records without having to manually look down the list and select all of the doctor A's because there will be other doctors other than Dr.A in there too. Basically I would like for the list to be able to grow and daily records added but the report to populate automatically as the list grows.

Thanks in advance and I hope I have made it clear. If not sorry and please ask away and I can clarify.
 
Upvote 0
I still don't know what your concern is, if I understand what you're saying, that's what the formula I provided does:


Excel 2010
AB
1DoctorDrug Dose mg
2Dr. A1
3Dr. B2
4Dr. A4
5Dr. A2
6Dr. A5
7Dr. C7
8Dr. C6
9Dr. C9
10Dr. C4
11Dr. Who3
12Dr. Who5
13Dr. A6
14Dr. C8
15Dr. Watson1
16Dr. Watson2
17Dr. Watson5
18Dr. A4
19Dr. Who6
20Dr. B9
21Dr. Pepper7
22Dr. Pepper8
23Dr. A2
Sheet2



Excel 2010
AB
1DoctorTotal Drug Dose mg
2Dr. A24
3Dr. B11
4Dr. C34
5Dr. Pepper15
6Dr. Watson8
7Dr. Who14
reporting
Cell Formulas
RangeFormula
B2=SUMIF(Sheet2!A$2:A$400,A2,Sheet2!B$2:B$400)


Look here: https://support.office.com/en-us/article/SUMIF-function-169b8c99-c05c-4483-a712-1697a653039b
 
Last edited:
Upvote 0
Oh I read the article there and get you now. That is brilliant. Thank you so much and sorry for the slow pickup. Must have been one of those nights lol :)
 
Upvote 0
That happens sometimes. You're welcome.
 
Upvote 0
Thanks Jtakw,

This worked a treat :)

On another note do you know how I could do the following 2 things: I would be ever so grateful

1) Return % of patients that received a certain drug by a certain Dr?

2) Return average dose

E.g Total Midazalam given divided by the number of patients that received it. I will call the result "Ave Dose" Also I was trying to have it unique to each doctor e.g Dr. A, Dr. B for the reporting page. I only want the excel to count the dose where patients actually received it. If a patient was not given it for any reason then I wish to leave it out of the calculation. Please see the below to show what I mean.

DoctorDose mgDoctorAverage Dose% Given
A2Dr. A2.5050.00%
B3Dr. B3.00100.00%
C1Dr. C1.00100.00%
A1
A0
A0

<tbody>
</tbody>
I was hoping there may be a formula like the sumif that may help. I tried the sumif formula with the countif but to no avail. I hope to hear from you soon. If anything is not clear please let me know and I will clarify. Thanks so much for the excellent help

I meant to add that the list of data will keep growing and so can change daily so if it is possible to have a formula like the sumif one you made that would be amazing as it just automatically updates the results as new data is added making the reporting really easy.
 
Last edited:
Upvote 0
Please clarify how you came up with 2.50 as "Average Dose" for "Dr. A" in your sample above.
Dr. A shows up 4 times in the far left column, administered 2 doses (2, and 1), the other 2 times, Dr. A did not (0, and 0). Then also, how is the "% Given" derived for Dr. A?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,115
Messages
6,128,915
Members
449,478
Latest member
Davenil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top