including in count if "still open"

sissajones

New Member
Joined
May 31, 2011
Messages
6
Hi All,
I have a dataset of service orders (SO) - the pertinent fields are OpenDate, ClosedDate.

I am trying to do essentially a crosstab type of result that would count "carryover" records in each month that it was a carryover.

**Carryover service orders are defined as not closed in the same month that they were opened. I already have the records filtered to those that meet this criteria.

The result that I want would result in something similar to this:

Shop Jan Feb Mar Apr May
ABC 3 5 3 5 2
DEF 5 3 1 2 4

The count shown above would include an SO if it was not opened in that month - it could be closed in that month. The problem comes when I have to count one that crosses multiple months - as it would be historically considered a "carryover"

e.g. a record opened in Jan and closed in April would be considered a "carryover" in Feb, Mar & Apr.

This is my very first post and I hope I have explained myself OK - thank you for your time and help!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi Sissa, welcome to the Board!

Create an expression like IIf(IsNull([ClosedDate]),"Yes",IIf(([ClosedDate]>[OpenDate]) And (Month([ClosedDate])<>Month([OpenDate])),"Yes","No"))

Filter on "Yes" and complete the crosstab.

Denis
 
Upvote 0
Hi Denis,

Thank you for your help - I'm not sure that will work - let me show the SQL below:

TRANSFORM Count(qry_SV_CarryoverRecordsOnly.WORK_ORDER) AS CountOfWORK_ORDER
SELECT qry_SV_CarryoverRecordsOnly.WORK_GROUP, Count(qry_SV_CarryoverRecordsOnly.WORK_ORDER) AS [Total Of WORK_ORDER]
FROM qry_SV_CarryoverRecordsOnly
WHERE (((qry_SV_CarryoverRecordsOnly.RAISED_YEAR)=[enter year]))
GROUP BY qry_SV_CarryoverRecordsOnly.WORK_GROUP
PIVOT Format([wo_closed_date],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");


I'm trying to have the record counted in each month that it is a carry over - so if it was opened in Jan and closed in May - it would be "counted" in Feb, Mar, Apr & May. I'm not sure how your IIF statement would ... I'm sure that its got to be something I put in the Count statement above to identify if the record should be included - I'm just not sure how to associate that with the appropriate column in the crosstab.

Again - thank you for your time!
 
Upvote 0
The Iif statement isn't directly associated with any columns.
Insert it into the query, change the grouping to Where, and uncheck the tick so it doesn't show.

As for doing the month by month, you could cheat...
Create another table with one field called MonthEnd. Enter the last day of each month for the year.
Add this table to the query but don't join it. You will get a cartesian join, with 12 records for each original record. By placing the MonthEnd field in the grid you can check whether any SO is open, month by month. That should then give you the pivot result that you need; but you may need to build the detail query first, then base the pivot on that.

Denis
 
Upvote 0
Denis - thank you - funnily enough I came to the same conclusion about 10 minutes before I read your suggestion - so I was already doing the snoopy happy dance :)

Thanks for your help
Sissa
 
Upvote 0

Forum statistics

Threads
1,216,389
Messages
6,130,323
Members
449,573
Latest member
bengee54

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