Help with reporting on data sheet.

Satele

New Member
Joined
May 20, 2014
Messages
30
Hi all,

I'm really struggling with this time-wise, though I know it can be done. I have two workbooks, one with my data, one with a report template. For simplicity, I've put some sample data from the data workbook in a separate sheet of the report workbook (attached if this is too confusing to follow).

My data worksheet can not be altered, and I need to use formulas on the report sheet to pull back data from the data sheet in an automated way.

In my data sheet, there are 10 columns of data:
A = UID
B = RecordType
C = HCode
D = AdmittedDate
E = Forename
F = Surname
G = DOB
H = Sex
I = STDate
R = RDate

An example of my reporting sheet is in the table below. What I need this sheet do might be fairly straight forward. If not, here's an explanation. Under 'Jul-12', I need the sheet to pull back the number of 'Assessments' and 'Reviews' completed in that month (reviews are in the form of 'transfers' and 'discharges' - 'Reviews' would just be a SUM of these two).

So far, this is fairly simple and could be achieved with SUMPRODUCT OR VLOOKUP. However, the difficulty is when I want to pull back the reviews, these need to be not just any review completed in that month but only reviews for the same patient who had an assessment, as determined by the 'UID' column in the data sheet.

Hospital Report
Reporting Quarer
Hospital NameHospital CodeRecord TypeJul-12Aug-12Sep-12
St GeorgeSTGE1Assessments
Reviews
Transfers
Discharges

<tbody>
</tbody>


An example of my data sheet:

UIDRecordTypeHCodeAdmittedDateForenameSurnameDOBSexSTDateRDate
89654STAssessSTGE101/01/2012AndrewMacbeth13/07/78m08/07/12
87676TransferSTGE101/01/2012MarkJones18/01/67m08/08/12
89654TransferSTGE101/01/2012AndrewMacbeth13/07/78m12/08/12
87637TransferSTGE101/01/2012SteveJones09/05/86m17/08/12
87676STAssessSTGE101/01/2012MarkJones02/07/12

<tbody>
</tbody>

So, in my report table above, the hospital code 'STGE1' should pull back the number 2 next to 'Assessments' under July. The formula should look for any records in the data sheet with a valid July 2012 date in the 'STDate' column. This part, I can do easily enough.

However, next to 'Transfers' in my report sheet, I only want to pull back the number of 'Transfer' records in the 'data' sheet with a corresponding 'Assessment' under 'RecordType'. i.e. the one with the UID 87637 Should not be counted. I also need the formula to only pull records that occur in the month as typed in the month for that particular column of the report sheet (cell D4: July 2012). All assessment dates are in the column 'STDate' and all review dates are in the column 'RDate'.

Can someone please help with this? I'm banging my head off a wall and need a fairly quick resolution!

Thank you,
S.
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I suspect that the reason you have had no replies yet is that you have made your question horrendously complicated.

Do you want to count ALL STdates for EACH Hcode for EACH month and likewise for Hcodes ?
 
Upvote 0
I suspect that the reason you have had no replies yet is that you have made your question horrendously complicated.

Do you want to count ALL STdates for EACH Hcode for EACH month and likewise for Hcodes ?

Hi oldbrewer,

Thanks for your reply. I realise it seems complicated, but couldn't think of a more succinct way to explain this.

Basically, the answer to that is yes, with one caveat. In the cell under ‘Jul-12’ and adjacent to ‘Assessments’, I do want to count all STDates for that particular HCode mentioned in the report for each month (in this case, July 2012). That’s straightforward enough.

What I then want in the cell adjacent to ‘Transfers’ is to a count of all records with an RDate for the particular HCode listed in B5 (STGE1) in each month, but only if these records have a corresponding ‘Assessment’ record for that month, counted in the cell above. I don’t want to count any records with an RDate for that month if they don’t have a corresponding record with an STDate, counted above.

The one unique field to a record is ‘UID’.

Apologies if I’m not being clear and thanks for your help.
 
Last edited:
Upvote 0
if you need a fairly quick solution I think you will need an intermediate sorting out of your data - I cannot see how to do it in one neat swoop.

Count of RecordTypeRecordType
UIDSTAssessTransferGrand Total
87637 11
87676112
89654112
Grand Total235
this simple pivot table can find all UID with transfer and assessment, so 89654 and 87676 can be ref points of a sumproduct formula that also screens by date month

<colgroup><col><col><col span="2"><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
if you need a fairly quick solution I think you will need an intermediate sorting out of your data - I cannot see how to do it in one neat swoop.

Count of RecordTypeRecordType
UIDSTAssessTransferGrand Total
8763711
87676112
89654112
Grand Total235
this simple pivot table can find all UID with transfer and assessment, so 89654 and 87676 can be ref points of a sumproduct formula that also screens by date month

<tbody>
</tbody>

Thanks. Would there be a way to create this pivot table as a separate sheet that knows how to reference the 'data' sheet automatically? That way, I could base my formulas off the pivot table, without user intervention.
 
Upvote 0
Normaly the pivot table is set up in a new sheet, when you make them.

The pivot table is linked to the data-sheet.

You have to refresh the pivot table, if you add new data to the data sheet.

Excel 2007 => data => refresh
 
Upvote 0
Thanks. On a related note, is there a way I can set up my formula to count all records with 'STDate' occurring in the month selected in D4, E4, F4. So for July, the data is in the format 02/07/2012 and I'd like all dates within 01/07/2012 - 31/07/2012 to be included.
 
Upvote 0
see my post #4 the months can be column headings and the "found" UID numbers can be row headings - just put in a suitable sumproduct formula
 
Upvote 0
I don't think I can use the pivot table solution. The 'data' sheet is actually contained in a separate .csv file. I've only included a sample of it in this workbook so that it was easier to write the formulae, then I was just going to change the references.

That's why I'm trying to find a formula-based solution.
 
Upvote 0
if you have a csv file you can set up a spreadsheet to pull in that data automatically, and then use that spreadsheet as the source for the pivot table.
 
Upvote 0

Forum statistics

Threads
1,215,551
Messages
6,125,478
Members
449,233
Latest member
Deardevil

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