It’s Christmas time again, and that means it’s time for another SQL query for Service Manager reporting. 🙂
This query gives you a dataset in list form to work with in Excel or PowerBI, containing the following informations related to Incident Requests.
ID
Classification
Closed Date
Created Date
Created Day
Created Month
Created Year
Created Week
First Response Date
Priority
Resolution Category
Resolved Date
Resolved Day
Resolved Month
Resolved Year
Resolved Week
Source
Status
TargetResolutionTime
TierQueue
You will need to run the SQL query against the Service Manager Data Warehouse database DWDataMart.
/****** Developed by Brian Fahrenholtz (Coretech A/S) ******/ SELECT '1' AS IncidentDimCount, I.Id, Classification = ISNULL(ClassificationEnumDS.DisplayName, ClassificationEnum.IncidentClassificationValue), Convert(Date,I.ClosedDate) As 'Closed Date', I.CreatedDate, DATEPART(DAY,I.CreatedDate) AS 'Created Day', DATEPART(MONTH,I.CreatedDate) AS 'Created Month', DATEPART(YEAR,I.CreatedDate) AS 'Created Year', DATEPART(WEEK,I.CreatedDate) AS 'Created Week', I.FirstResponseDate AS 'First Response Date', I.Priority, ResolutionCategory = ISNULL(ResolutionCategoryDS.DisplayName, ResolutionCategoryEnum.IncidentResolutionCategoryValue), I.ResolvedDate AS 'Resolved Date', DATEPART(DAY,I.ResolvedDate) AS 'Resolved Day', DATEPART(MONTH,I.ResolvedDate) AS 'Resolved Month', DATEPART(YEAR,I.ResolvedDate) AS 'Resolved Year', DATEPART(WEEK,I.ResolvedDate) AS 'Resolved Week', Source = ISNULL(SourceDS.DisplayName, SourceEnum.IncidentSourceValue), Status = ISNULL(StatusDS.DisplayName, StatusEnum.IncidentStatusValue), I.TargetResolutionTime, TierQueue = ISNULL(TierQueueEnumDS.DisplayName, TierQueueEnum.IncidentTierQueuesValue) FROM DWDataMart.dbo.IncidentDimvw I INNER JOIN DWDAtaMart.dbo.EntityDimvw Entity ON I.EntityDimKey = Entity.EntityDimKey INNER JOIN DWDAtaMart.dbo.WorkItemDimvw WI ON I.EntityDimKey = WI.EntityDimKey /****** Tier Queue ******/ Left Outer Join DWDataMart.dbo.IncidentTierQueuesvw TierQueueEnum ON I.TierQueue_IncidentTierQueuesId = TierQueueEnum.IncidentTierQueuesId Left Outer Join DWDataMart.dbo.DisplayStringDimvw TierQueueEnumDS ON TierQueueEnum.EnumTypeId = TierQueueEnumDS.BaseManagedEntityId AND TierQueueEnumDS.LanguageCode = 'ENU' /****** Source ******/ LEFT OUTER JOIN DWDataMart.dbo.IncidentSourcevw AS SourceEnum ON SourceEnum.IncidentSourceId = I.Source_IncidentSourceId LEFT OUTER JOIN DWDataMart.dbo.DisplayStringDimvw SourceDS ON SourceEnum.EnumTypeId=SourceDS.BaseManagedEntityId AND SourceDS.LanguageCode = 'ENU' /****** Resolution Category ******/ LEFT OUTER JOIN DWDataMart.dbo.IncidentResolutionCategoryvw AS ResolutionCategoryEnum ON ResolutionCategoryEnum.IncidentResolutionCategoryId = I.ResolutionCategory_IncidentResolutionCategoryId LEFT OUTER JOIN DWDataMart.dbo.DisplayStringDimvw AS ResolutionCategoryDS ON ResolutionCategoryEnum.EnumTypeId=ResolutionCategoryDS.BaseManagedEntityId AND ResolutionCategoryDS.LanguageCode = 'ENU' /****** Classification ******/ Left Outer Join DWDataMart.dbo.IncidentClassificationvw ClassificationEnum ON I.Classification_IncidentClassificationId = ClassificationEnum.IncidentClassificationId Left Outer Join DWDataMart.dbo.DisplayStringDimvw ClassificationEnumDS ON ClassificationEnum.EnumTypeId = ClassificationEnumDS.BaseManagedEntityId AND ClassificationEnumDS.LanguageCode = 'ENU' /****** Status ******/ LEFT OUTER JOIN DWDataMart.dbo.IncidentStatusvw AS StatusEnum ON StatusEnum.IncidentStatusId = I.Status_IncidentStatusId LEFT OUTER JOIN DWDataMart.dbo.DisplayStringDimvw StatusDS ON StatusEnum.EnumTypeId=StatusDS.BaseManagedEntityId AND StatusDS.LanguageCode = 'ENU' Order by I.CreatedDate
The output will be like below, when you using it in Excel.
Mary Christmas
This seems pretty useful, is there a way where this incident dataset is available for download? thanks
You can mark and copy the SQL query, and then paste it into a SQL query or Excel data connection.
Hi, thank you for the query. Is there a way to get the info about incident escalation? To be exact escalation history of all incidents so we can see everyone that incident was at.
Hi Vibor, the escalation property can easily be added to this query. It is more difficult with the history.
Thank you very much for a fast reply Brian. Yes i agree it is hard to find the history. I am begining to think it is even impossible.
This is awesome. Question: Is there an easy way you could add the fields that are required for the calculation for “Active Work” time per incident. In other words the difference between created and resolved dates minus the time that it is in a “clock stopped” phase?
Hi Josh,
It’s two differens things. One is the time between created and resolved that should be easy to add, the second “clock stopped” is based on time working on the workitem. That information is located in another tabel in the database, but can be added to this as well.
Brian,
Can you please get a query to list all the service requests?
Thanks
/****** Developed by Brian Fahrenholtz (Coretech A/S) ******/
SELECT
‘1’ AS SRDimCount,
SR.Id,
Classification = ISNULL(AreaEnumDS.DisplayName, AreaEnum.ServiceRequestAreaValue),
Convert(Date,SR.CompletedDate) As ‘Completed Date’,
SR.CreatedDate,
DATEPART(DAY,SR.CreatedDate) AS ‘Created Day’,
DATEPART(MONTH,SR.CreatedDate) AS ‘Created Month’,
DATEPART(YEAR,SR.CreatedDate) AS ‘Created Year’,
DATEPART(WEEK,SR.CreatedDate) AS ‘Created Week’,
SR.FirstResponseDate AS ‘First Response Date’,
SR.Priority,
SR.CompletedDate AS ‘Completed Date’,
DATEPART(DAY,SR.CompletedDate) AS ‘Completed Day’,
DATEPART(MONTH,SR.CompletedDate) AS ‘Completed Month’,
DATEPART(YEAR,SR.CompletedDate) AS ‘Completed Year’,
DATEPART(WEEK,SR.CompletedDate) AS ‘Completed Week’,
Source = ISNULL(SourceDS.DisplayName, SourceEnum.ServiceRequestSourceValue),
Status = ISNULL(StatusDS.DisplayName, StatusEnum.ServiceRequestStatusValue),
SupportGroup = ISNULL(SupportGroupEnumDS.DisplayName, SupportGroupEnum.ServiceRequestSupportGroupValue)
FROM
DWDataMart.dbo.ServiceRequestDimvw SR
INNER JOIN DWDAtaMart.dbo.EntityDimvw Entity
ON SR.EntityDimKey = Entity.EntityDimKey
INNER JOIN DWDAtaMart.dbo.WorkItemDimvw WI
ON SR.EntityDimKey = WI.EntityDimKey
/****** Tier Queue ******/
Left Outer Join DWDataMart.dbo.ServiceRequestSupportGroupvw SupportGroupEnum
ON SR.SupportGroup_ServiceRequestSupportGroupId = SupportGroupEnum.ServiceRequestSupportGroupId
Left Outer Join DWDataMart.dbo.DisplayStringDimvw SupportGroupEnumDS
ON SupportGroupEnum.EnumTypeId = SupportGroupEnumDS.BaseManagedEntityId
AND SupportGroupEnumDS.LanguageCode = ‘ENU’
/****** Source ******/
LEFT OUTER JOIN
DWDataMart.dbo.ServiceRequestSourcevw AS SourceEnum
ON SourceEnum.ServiceRequestSourceId = SR.Source_ServiceRequestSourceId
LEFT OUTER JOIN
DWDataMart.dbo.DisplayStringDimvw SourceDS
ON SourceEnum.EnumTypeId=SourceDS.BaseManagedEntityId
AND SourceDS.LanguageCode = ‘ENU’
/****** Classification ******/
Left Outer Join DWDataMart.dbo.ServiceRequestAreavw AreaEnum
ON SR.Area_ServiceRequestAreaId = AreaEnum.ServiceRequestAreaId
Left Outer Join DWDataMart.dbo.DisplayStringDimvw AreaEnumDS
ON AreaEnum.EnumTypeId = AreaEnumDS.BaseManagedEntityId
AND AreaEnumDS.LanguageCode = ‘ENU’
/****** Status ******/
LEFT OUTER JOIN
DWDataMart.dbo.ServiceRequestStatusvw AS StatusEnum
ON StatusEnum.ServiceRequestStatusId= SR.Status_ServiceRequestStatusId
LEFT OUTER JOIN
DWDataMart.dbo.DisplayStringDimvw StatusDS
ON StatusEnum.EnumTypeId=StatusDS.BaseManagedEntityId
AND StatusDS.LanguageCode = ‘ENU’
Order by SR.CreatedDate
Is there a way I can get resolved by user info for SR ticket
Thanks you for this.
It will be awesome if you can share some Service Request Queries / Datasets.
Is there a way I can get resolved by user info for SR ticket