Default300
Board Regular
- Joined
- Jul 13, 2009
- Messages
- 83
Hi. Can you help me solve this puzzle? Hope so.
I've begun by showing the setup I have, but if you want to read the task and problem first, they're stated below.
Tables have been stripped down to the essential columns; and cell references and sheet names have been simplified.
SCENARIO / SETUP
Table 1 (DeviceDetails) (I'll call the worksheet DvcDtl for this example)
Table of Devices.
Each row / record refers to a single Device with a unique DeviceID, with various Details of that device listed in columns / fields.
There is exactly 1 row / record for each Device.
<tbody>
[TH="align: left"] State
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"] Existing
[/TH]
[TH="align: left"] Proposed / New
[/TH]
[TH="align: left"] Content
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"] Constant
[/TH]
[TH="align: left"] Formula
[/TH]
[TH="align: left"] DataType
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"] Integer
[/TH]
[TH="align: left"] Date
[/TH]
[TH="align: left"] Format
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"] 0000
[/TH]
[TH="align: left"] dd/mm/yyyy
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"][/TH]
[TH="align: left"] A
[/TH]
[TH="align: left"] B
[/TH]
[TH="align: left"] Header
[/TH]
[TH="align: left"] 1
[/TH]
[TH="align: left"] DeviceID
[/TH]
[TH="align: left"] LatestPrintDate
[/TH]
[TH="align: left"] Data
[/TH]
[TH="align: left"] 2
[/TH]
[TH="align: right"] 0111
[/TH]
[TH="align: right"] 31/12/2001
[/TH]
[TH="align: left"] Data
[/TH]
[TH="align: left"] 3
[/TH]
[TH="align: right"] 0222
[/TH]
[TH="align: right"] 29/10/2001
[/TH]
[TH="align: left"] Data
[/TH]
[TH="align: left"] 4
[/TH]
[TH="align: right"] 0333
[/TH]
[TH="align: right"] 30/11/2001
[/TH]
</tbody>
Table 2 (ServiceRecords) (I'll call the worksheet SrvRcd for this example)
Table of Service Records for devices.
Each row is a single Service Event with a unique ServiceEventID, and concerns a single device identified by its unique DeviceID.
There is exactly 1 row / record for each ServiceEvent.
But there may be 0, 1 or multiple ServiceEvents for each Device.
If it were a relational database, then the relationship between the DeviceDetails table and the ServiceRecords table (for the DeviceID field) would be referred to as "one-to-many".
[TABLE="width: 500"]
<tbody>[TR]
[TH="align: left"]State
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]Existing
[/TH]
[TH="align: left"]Existing
[/TH]
[TH="align: left"]Existing
[/TH]
[TH="align: left"]Existing
[/TH]
[TH="align: left"]Proposed / New
[/TH]
[/TR]
[TR]
[TH="align: left"]Content
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]Constant
[/TH]
[TH="align: left"]Constant
[/TH]
[TH="align: left"]Constant
[/TH]
[TH="align: left"]Constant
[/TH]
[TH="align: left"]Formula
[/TH]
[/TR]
[TR]
[TH="align: left"]DataType
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]Integer
[/TH]
[TH="align: left"]Integer
[/TH]
[TH="align: left"]Text
[/TH]
[TH="align: left"]Date
[/TH]
[TH="align: left"]Date
[/TH]
[/TR]
[TR]
[TH="align: left"]Format
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]0000
[/TH]
[TH="align: left"]0000
[/TH]
[TH="align: left"]General
[/TH]
[TH="align: left"]dd/mm/yyyy
[/TH]
[TH="align: left"]dd/mm/yyyy
[/TH]
[/TR]
[TR]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[/TR]
[TR]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]A
[/TH]
[TH="align: left"]B
[/TH]
[TH="align: left"]C
[/TH]
[TH="align: left"]D
[/TH]
[TH="align: left"]E
[/TH]
[/TR]
[TR]
[TH="align: left"]Header
[/TH]
[TH="align: left"]1
[/TH]
[TH="align: left"]ServiceEventID
[/TH]
[TH="align: left"]DeviceID
[/TH]
[TH="align: left"]ServiceDocType
[/TH]
[TH="align: left"]ServiceDocDate
[/TH]
[TH="align: left"]LatestPrintDate
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]2
[/TH]
[TH="align: right"]0995
[/TH]
[TH="align: right"]0111
[/TH]
[TH="align: left"]Printed
[/TH]
[TH="align: right"]29/10/2001
[/TH]
[TH="align: right"]31/12/2001
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]3
[/TH]
[TH="align: right"]0996
[/TH]
[TH="align: right"]0333
[/TH]
[TH="align: left"]Written
[/TH]
[TH="align: right"]29/10/2001
[/TH]
[TH="align: right"]30/11/2001
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]4
[/TH]
[TH="align: right"]0997
[/TH]
[TH="align: right"]0222
[/TH]
[TH="align: left"]Printed
[/TH]
[TH="align: right"]29/10/2001
[/TH]
[TH="align: right"]29/10/2001
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]5
[/TH]
[TH="align: right"]0998
[/TH]
[TH="align: right"]0111
[/TH]
[TH="align: left"]Written
[/TH]
[TH="align: right"]30/11/2001
[/TH]
[TH="align: right"]31/12/2001
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]6
[/TH]
[TH="align: right"]0999
[/TH]
[TH="align: right"]0333
[/TH]
[TH="align: left"]Printed
[/TH]
[TH="align: right"]30/11/2001
[/TH]
[TH="align: right"]30/11/2001
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]7
[/TH]
[TH="align: right"]1000
[/TH]
[TH="align: right"]0111
[/TH]
[TH="align: left"]Printed
[/TH]
[TH="align: right"]31/12/2001
[/TH]
[TH="align: right"]31/12/2001
[/TH]
[/TR]
</tbody>[/TABLE]
TASK
I want to know what was the most recent date on which a service record was printed (as opposed to written), for each device.
What formula should I use in LatestPrintDate column, to return the date shown?
NB: The LatestPrintDate column can be in either Table, though I think it makes more sense in the DeviceDetails table, where the calculation would be performed once for each device.
It's possible to introduce one or more new columns in either table if required. In fact I'd prefer to have more columns than a very convoluted nested formula.
I'd prefer not to use an array formula. If I must, then I'd prefer one contained within a single cell rather than stretched across a full column.
I'd like to use SUMPRODUCT if possible, as I find that syntax easy to read and edit.
Perhaps MAX, LARGE and/or SUBTOTAL has a part to play (to return the latest date).
If using LARGE, I'd prefer to use a constant to define parameter "K", rather than to use ROW().
If lookups are required, then I prefer INDEX + MATCH rather than VLOOKUP etc.
ATTEMPTED SOLUTION
If inserting proposed new column into the DeviceDetails Table (NOT ServiceRecords Table), then perhaps something similar to this...
=SUMPRODUCT(('SerRec'!$A$2:$A$7='DvcDtl'!$A2)*('SerRec'!$C$2:$C$7="Printed")*(MAX('SerRec'!$D$2:$D$7)))
PROBLEM
Date returned by above formula is wrong.
It is returning the same maximum date for all devices (not the specific device referenced).
It then multiplies this date by the number of instances that the specific device has had a service record printed.
Not what I want, obviously!
Any ideas?
Thanks in advance.
(BTW the table reformatted the alignment of all cells to centered, despite careful setup)
I've begun by showing the setup I have, but if you want to read the task and problem first, they're stated below.
Tables have been stripped down to the essential columns; and cell references and sheet names have been simplified.
SCENARIO / SETUP
Table 1 (DeviceDetails) (I'll call the worksheet DvcDtl for this example)
Table of Devices.
Each row / record refers to a single Device with a unique DeviceID, with various Details of that device listed in columns / fields.
There is exactly 1 row / record for each Device.
<tbody>
[TH="align: left"] State
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"] Existing
[/TH]
[TH="align: left"] Proposed / New
[/TH]
[TH="align: left"] Content
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"] Constant
[/TH]
[TH="align: left"] Formula
[/TH]
[TH="align: left"] DataType
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"] Integer
[/TH]
[TH="align: left"] Date
[/TH]
[TH="align: left"] Format
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"] 0000
[/TH]
[TH="align: left"] dd/mm/yyyy
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"][/TH]
[TH="align: left"] A
[/TH]
[TH="align: left"] B
[/TH]
[TH="align: left"] Header
[/TH]
[TH="align: left"] 1
[/TH]
[TH="align: left"] DeviceID
[/TH]
[TH="align: left"] LatestPrintDate
[/TH]
[TH="align: left"] Data
[/TH]
[TH="align: left"] 2
[/TH]
[TH="align: right"] 0111
[/TH]
[TH="align: right"] 31/12/2001
[/TH]
[TH="align: left"] Data
[/TH]
[TH="align: left"] 3
[/TH]
[TH="align: right"] 0222
[/TH]
[TH="align: right"] 29/10/2001
[/TH]
[TH="align: left"] Data
[/TH]
[TH="align: left"] 4
[/TH]
[TH="align: right"] 0333
[/TH]
[TH="align: right"] 30/11/2001
[/TH]
</tbody>
Table 2 (ServiceRecords) (I'll call the worksheet SrvRcd for this example)
Table of Service Records for devices.
Each row is a single Service Event with a unique ServiceEventID, and concerns a single device identified by its unique DeviceID.
There is exactly 1 row / record for each ServiceEvent.
But there may be 0, 1 or multiple ServiceEvents for each Device.
If it were a relational database, then the relationship between the DeviceDetails table and the ServiceRecords table (for the DeviceID field) would be referred to as "one-to-many".
[TABLE="width: 500"]
<tbody>[TR]
[TH="align: left"]State
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]Existing
[/TH]
[TH="align: left"]Existing
[/TH]
[TH="align: left"]Existing
[/TH]
[TH="align: left"]Existing
[/TH]
[TH="align: left"]Proposed / New
[/TH]
[/TR]
[TR]
[TH="align: left"]Content
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]Constant
[/TH]
[TH="align: left"]Constant
[/TH]
[TH="align: left"]Constant
[/TH]
[TH="align: left"]Constant
[/TH]
[TH="align: left"]Formula
[/TH]
[/TR]
[TR]
[TH="align: left"]DataType
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]Integer
[/TH]
[TH="align: left"]Integer
[/TH]
[TH="align: left"]Text
[/TH]
[TH="align: left"]Date
[/TH]
[TH="align: left"]Date
[/TH]
[/TR]
[TR]
[TH="align: left"]Format
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]0000
[/TH]
[TH="align: left"]0000
[/TH]
[TH="align: left"]General
[/TH]
[TH="align: left"]dd/mm/yyyy
[/TH]
[TH="align: left"]dd/mm/yyyy
[/TH]
[/TR]
[TR]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[/TR]
[TR]
[TH="align: left"]
[/TH]
[TH="align: left"]
[/TH]
[TH="align: left"]A
[/TH]
[TH="align: left"]B
[/TH]
[TH="align: left"]C
[/TH]
[TH="align: left"]D
[/TH]
[TH="align: left"]E
[/TH]
[/TR]
[TR]
[TH="align: left"]Header
[/TH]
[TH="align: left"]1
[/TH]
[TH="align: left"]ServiceEventID
[/TH]
[TH="align: left"]DeviceID
[/TH]
[TH="align: left"]ServiceDocType
[/TH]
[TH="align: left"]ServiceDocDate
[/TH]
[TH="align: left"]LatestPrintDate
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]2
[/TH]
[TH="align: right"]0995
[/TH]
[TH="align: right"]0111
[/TH]
[TH="align: left"]Printed
[/TH]
[TH="align: right"]29/10/2001
[/TH]
[TH="align: right"]31/12/2001
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]3
[/TH]
[TH="align: right"]0996
[/TH]
[TH="align: right"]0333
[/TH]
[TH="align: left"]Written
[/TH]
[TH="align: right"]29/10/2001
[/TH]
[TH="align: right"]30/11/2001
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]4
[/TH]
[TH="align: right"]0997
[/TH]
[TH="align: right"]0222
[/TH]
[TH="align: left"]Printed
[/TH]
[TH="align: right"]29/10/2001
[/TH]
[TH="align: right"]29/10/2001
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]5
[/TH]
[TH="align: right"]0998
[/TH]
[TH="align: right"]0111
[/TH]
[TH="align: left"]Written
[/TH]
[TH="align: right"]30/11/2001
[/TH]
[TH="align: right"]31/12/2001
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]6
[/TH]
[TH="align: right"]0999
[/TH]
[TH="align: right"]0333
[/TH]
[TH="align: left"]Printed
[/TH]
[TH="align: right"]30/11/2001
[/TH]
[TH="align: right"]30/11/2001
[/TH]
[/TR]
[TR]
[TH="align: left"]Data
[/TH]
[TH="align: left"]7
[/TH]
[TH="align: right"]1000
[/TH]
[TH="align: right"]0111
[/TH]
[TH="align: left"]Printed
[/TH]
[TH="align: right"]31/12/2001
[/TH]
[TH="align: right"]31/12/2001
[/TH]
[/TR]
</tbody>[/TABLE]
TASK
I want to know what was the most recent date on which a service record was printed (as opposed to written), for each device.
What formula should I use in LatestPrintDate column, to return the date shown?
NB: The LatestPrintDate column can be in either Table, though I think it makes more sense in the DeviceDetails table, where the calculation would be performed once for each device.
It's possible to introduce one or more new columns in either table if required. In fact I'd prefer to have more columns than a very convoluted nested formula.
I'd prefer not to use an array formula. If I must, then I'd prefer one contained within a single cell rather than stretched across a full column.
I'd like to use SUMPRODUCT if possible, as I find that syntax easy to read and edit.
Perhaps MAX, LARGE and/or SUBTOTAL has a part to play (to return the latest date).
If using LARGE, I'd prefer to use a constant to define parameter "K", rather than to use ROW().
If lookups are required, then I prefer INDEX + MATCH rather than VLOOKUP etc.
ATTEMPTED SOLUTION
If inserting proposed new column into the DeviceDetails Table (NOT ServiceRecords Table), then perhaps something similar to this...
=SUMPRODUCT(('SerRec'!$A$2:$A$7='DvcDtl'!$A2)*('SerRec'!$C$2:$C$7="Printed")*(MAX('SerRec'!$D$2:$D$7)))
PROBLEM
Date returned by above formula is wrong.
It is returning the same maximum date for all devices (not the specific device referenced).
It then multiplies this date by the number of instances that the specific device has had a service record printed.
Not what I want, obviously!
Any ideas?
Thanks in advance.
(BTW the table reformatted the alignment of all cells to centered, despite careful setup)