KPI queries
You can use the queries in this article to create data visualizations similar to those in Enhanced Analytics.
Prerequisites
Before you begin, you must
-
Establish a connection with your Business Intelligence (BI) tool:
Once you establish a connection, you can use the queries in this article to extract and visualize data.
Projects completed
The Projects completed KPI shows how many projects within the filtered time period have been completed, as well as how the percentage increased or decreased since the previous time period.
You can also see the number of projects completed in the previous time period, as well as the number of days in the previous time period.
Query
WITH completedProjectsInRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 COUNT(t0.PROJECTID) as PROJECT_COUNT
聽聽聽 FROM PROJECTS_CURRENT t0
聽聽聽 WHERE t0.ACTUALCOMPLETIONDATE >= '2025-01-01'
聽聽聽聽聽聽聽 AND t0.ACTUALCOMPLETIONDATE <= '2025-01-31'
), completedProjectsPreviousRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 COUNT(t0.PROJECTID) as PROJECT_COUNT
聽聽聽 FROM PROJECTS_CURRENT t0
聽聽聽 WHERE t0.ACTUALCOMPLETIONDATE >= '2024-12-01'
聽聽聽聽聽聽聽 AND t0.ACTUALCOMPLETIONDATE <= '2024-12-31'
), rawChange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 (a.PROJECT_COUNT - b.PROJECT_COUNT) as CHANGE_FROM_PREVIOUS_PERIOD
聽聽聽 FROM completedProjectsInRange a, completedProjectsPreviousRange b
), percentChange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 CASE
聽聽聽聽聽聽聽聽聽聽聽 WHEN a.PROJECT_COUNT = b.PROJECT_COUNT THEN 0.00
聽聽聽聽聽聽聽聽聽聽聽 WHEN b.PROJECT_COUNT > 0 THEN ((a.PROJECT_COUNT - b.PROJECT_COUNT) / b.PROJECT_COUNT * 100)
聽聽聽聽聽聽聽 END AS PERCENT_CHANGE_FROM_PREVIOUS_PERIOD
聽聽聽 FROM completedProjectsInRange a, completedProjectsPreviousRange b
)
SELECT
聽聽聽 a.PROJECT_COUNT,
聽聽聽 b.PROJECT_COUNT as PREVIOUS_PROJECT_COUNT,
聽聽聽 c.CHANGE_FROM_PREVIOUS_PERIOD,
聽聽聽 d.PERCENT_CHANGE_FROM_PREVIOUS_PERIOD
FROM completedProjectsInRange a, completedProjectsPreviousRange b, rawChange c,
percentChange d
Projects completed on time
The Projects completed on time KPI shows the percentage of projects within the filtered time period that were completed on time, as well as how the percentage increased or decreased since the previous time period.
You can also see the percentage of projects completed on time in the previous time period, as well as the number of days in the previous time period.
WITH completedProjectsInRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 COUNT(t0.PROJECTID) as PROJECT_COUNT
聽聽聽 FROM PROJECTS_CURRENT t0
聽聽聽 WHERE t0.ACTUALCOMPLETIONDATE >= '2025-01-01'
聽聽聽聽聽聽聽 AND t0.ACTUALCOMPLETIONDATE <= '2025-01-31'
), completedOntimeProjectsInRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 COUNT(t0.PROJECTID) as PROJECT_COUNT
聽聽聽 FROM PROJECTS_CURRENT t0
聽聽聽 WHERE t0.ACTUALCOMPLETIONDATE >= '2025-01-01'
聽聽聽聽聽聽聽 AND t0.ACTUALCOMPLETIONDATE <= '2025-01-31'
聽聽聽聽聽聽聽 AND t0.PROGRESSSTATUS = 'ON'
), percentOntimeProjects as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 CASE
聽聽聽聽聽聽聽聽聽聽聽 WHEN a.PROJECT_COUNT = 0 THEN 0
聽聽聽聽聽聽聽聽聽聽聽 ELSE ROUND(b.PROJECT_COUNT/a.PROJECT_COUNT) * 100
聽聽聽聽聽聽聽 END as ONTIMEPROJECTPERCENT
聽聽聽 FROM completedProjectsInRange a, completedOntimeProjectsInRange b
), completedProjectsPreviousRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 COUNT(t0.PROJECTID) as PROJECT_COUNT
聽聽聽 FROM PROJECTS_CURRENT t0
聽聽聽 WHERE t0.ACTUALCOMPLETIONDATE >= '2024-12-01'
聽聽聽聽聽聽聽 AND t0.ACTUALCOMPLETIONDATE <= '2024-12-31'
), completedOntimeProjectsPreviousRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 COUNT(t0.PROJECTID) as PROJECT_COUNT
聽聽聽 FROM PROJECTS_CURRENT t0
聽聽聽 WHERE t0.ACTUALCOMPLETIONDATE >= '2024-12-01'
聽聽聽聽聽聽聽 AND t0.ACTUALCOMPLETIONDATE <= '2024-12-31'
聽聽聽聽聽聽聽 AND t0.PROGRESSSTATUS = 'ON'
), percentOntimeProjectsPreviousRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 CASE
聽聽聽聽聽聽聽聽聽聽聽 WHEN a.PROJECT_COUNT = 0 THEN 0
聽聽聽聽聽聽聽聽聽聽聽 ELSE ROUND(b.PROJECT_COUNT/a.PROJECT_COUNT) * 100
聽聽聽聽聽聽聽 END as ONTIMEPROJECTPERCENT
聽聽聽 FROM completedProjectsPreviousRange a, completedOntimeProjectsPreviousRange b
), rawChange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 (a.ONTIMEPROJECTPERCENT - b.ONTIMEPROJECTPERCENT) as CHANGE_FROM_PREVIOUS_PERIOD
聽聽聽 FROM percentOntimeProjects a, percentOntimeProjectsPreviousRange b
), percentChange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 CASE
聽聽聽聽聽聽聽聽聽聽聽 WHEN a.ONTIMEPROJECTPERCENT = b.ONTIMEPROJECTPERCENT THEN 0
聽聽聽聽聽聽聽聽聽聽聽 WHEN b.ONTIMEPROJECTPERCENT > 0 THEN ((a.ONTIMEPROJECTPERCENT - b.ONTIMEPROJECTPERCENT) / b.ONTIMEPROJECTPERCENT * 100)
聽聽聽聽聽聽聽 END AS PERCENT_CHANGE_FROM_PREVIOUS_PERIOD
聽聽聽 FROM percentOntimeProjects a, percentOntimeProjectsPreviousRange b
)
SELECT
聽聽聽 a.ONTIMEPROJECTPERCENT,
聽聽聽 b.ONTIMEPROJECTPERCENT as PREVIOUS_ONTIMEPROJECTPERCENT,
聽聽聽 c.CHANGE_FROM_PREVIOUS_PERIOD,
聽聽聽 d.PERCENT_CHANGE_FROM_PREVIOUS_PERIOD
FROM percentOntimeProjects a, percentOntimeProjectsPreviousRange b, rawChange c,
percentChange d
Avg. project duration
The Avg. project duration KPI shows the average amount of completion time鈥攊n days, weeks, or years鈥攆or projects with actual end dates within the filtered time period, as well as how the percentage increased or decreased since the previous time period.
You can also see the average amount of completion time for projects with actual end dates in the previous time period, as well as the number of days in the previous time period.
WITH averageProjectDurationInRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 AVG(t0.ACTUALDURATIONMINUTES) as AVERAGE_PROJECT_DURATION
聽聽聽 FROM PROJECTS_CURRENT t0
聽聽聽 WHERE t0.ACTUALCOMPLETIONDATE >= '2025-01-01'
聽聽聽聽聽聽聽 AND t0.ACTUALCOMPLETIONDATE <= '2025-01-31'
), averageProjectPreviousRange as (
聽聽聽 SELECT AVG (t0. ACTUALDURATIONMINUTES) as AVERAGE_PROJECT_DURATION FROM PROJECTS_CURRENT t0
聽聽聽 WHERE t0.ACTUALCOMPLETIONDATE >= '2024-12-01'
聽聽聽聽聽聽聽 AND t0.ACTUALCOMPLETIONDATE <= '2024-12-31'
), rawChange as (
聽聽聽 SELECT ((a.AVERAGE_PROJECT_DURATION - b.AVERAGE_PROJECT_DURATION) / 480) as CHANGE_FROM_PREVIOUS_PERIOD FROM averageProjectDurationInRange a, averageProjectPreviousRange b
), percentChange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 CASE
聽聽聽聽聽聽聽聽聽聽聽 WHEN a.AVERAGE_PROJECT_DURATION = b.AVERAGE_PROJECT_DURATION THEN 0
聽聽聽聽聽聽聽聽聽聽聽 WHEN b.AVERAGE_PROJECT_DURATION > 0 THEN ((a.AVERAGE_PROJECT_DURATION - b.AVERAGE_PROJECT_DURATION)聽 / b.AVERAGE_PROJECT_DURATION) * 100
聽聽聽聽聽聽聽 END AS PERCENT_CHANGE_FROM_PREVIOUS_PERIOD
聽聽聽聽聽聽聽 FROM averageProjectDurationInRange a, averageProjectPreviousRange b
)
SELECT
聽聽聽 a.AVERAGE_PROJECT_DURATION,
聽聽聽 b.AVERAGE_PROJECT_DURATION as PREVIOUS_AVERAGE_PROJECT_DURATION,
聽聽聽 c.CHANGE_FROM_PREVIOUS_PERIOD,
聽聽聽 d.PERCENT_CHANGE_FROM_PREVIOUS_PERIOD
FROM averageProjectDurationInRange a, averageProjectPreviousRange b, rawChange c,
percentChange d
Average tasks per project
The Avg, tasks per project KPI shows the average number of tasks assigned to projects within the filtered time period, as well as how the percentage increased or decreased since the previous time period.
You can also see the average number of tasks assigned to projects in the previous time period, as well as the number of days in the previous time period.
WITH tasksPerProjectInRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 COUNT(t0.TASKID) as TASK_COUNT
聽聽聽 FROM TASKS_CURRENT t0
聽聽聽聽聽聽聽 LEFT JOIN PROJECTS_CURRENT t1 ON t1.PROJECTID = t0.PROJECTID
聽聽聽 WHERE
聽聽聽聽聽聽聽 (
聽聽聽聽聽聽聽聽聽聽聽 t1.PLANNEDSTARTDATE >= '2025-01-01'
聽聽聽聽聽聽聽聽聽聽聽 AND t1.PLANNEDSTARTDATE <= '2025-01-31'
聽聽聽聽聽聽聽 )
聽聽聽聽聽聽聽 OR (
聽聽聽聽聽聽聽聽聽聽聽 t1.PLANNEDCOMPLETIONDATE >= '2025-01-01'
聽聽聽聽聽聽聽聽聽聽聽 AND t1. PLANNEDCOMPLETIONDATE <= '2025-01-31'
聽聽聽聽聽聽聽 )
聽聽聽聽聽聽聽 OR (
聽聽聽聽聽聽聽聽聽聽聽 t1.PLANNEDSTARTDATE <= '2025-01-01'
聽聽聽聽聽聽聽聽聽聽聽 AND t1. PLANNEDCOMPLETIONDATE >= '2025-01-31'
聽聽聽聽聽聽聽 )
聽聽聽 GROUP BY t0.PROJECTID
), averageTasksPerProjectInRange as (
聽聽聽 SELECT AVG(TASK_COUNT) AS AVERAGE_TASK_COUNT FROM tasksPerProjectInRange
), tasksPerProjectInPreviousRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 COUNT(t0.TASKID) as TASK_COUNT
聽聽聽 FROM TASKS_CURRENT t0
聽聽聽聽聽聽聽 LEFT JOIN PROJECTS_CURRENT t1 ON t1.PROJECTID = t0.PROJECTID
聽聽聽 WHERE
聽聽聽聽聽聽聽 (
聽聽聽聽聽聽聽聽聽聽聽 t1.PLANNEDSTARTDATE >= '2024-12-01'
聽聽聽聽聽聽聽聽聽聽聽 AND t1.PLANNEDSTARTDATE <= '2024-12-31'
聽聽聽聽聽聽聽 )
聽聽聽聽聽聽聽 OR (
聽聽聽聽聽聽聽聽聽聽聽 t1.PLANNEDCOMPLETIONDATE >= '2024-12-01'
聽聽聽聽聽聽聽聽聽聽聽 AND t1. PLANNEDCOMPLETIONDATE <= '2024-12-31'
聽聽聽聽聽聽聽 )
聽聽聽聽聽聽聽 OR (
聽聽聽聽聽聽聽聽聽聽聽 t1.PLANNEDSTARTDATE <= '2024-12-01'
聽聽聽聽聽聽聽聽聽聽聽 AND t1. PLANNEDCOMPLETIONDATE >= '2024-12-31'
聽聽聽聽聽聽聽 )
聽聽聽 GROUP BY t0.PROJECTID
), averageTasksPerProjectInPreviousRange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 AVG(TASK_COUNT) AS AVERAGE_TASK_COUNT
聽聽聽聽聽聽聽 FROM tasksPerProjectInPreviousRange
), rawChange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 (a.AVERAGE_TASK_COUNT - b.AVERAGE_TASK_COUNT) as CHANGE_FROM_PREVIOUS_PERIOD
聽聽聽 FROM averageTasksPerProjectInRange a, averageTasksPerProjectInPreviousRange b
), percentChange as (
聽聽聽 SELECT
聽聽聽聽聽聽聽 CASE
聽聽聽聽聽聽聽聽聽聽聽 WHEN a.AVERAGE_TASK_COUNT = b.AVERAGE_TASK_COUNT THEN 0
聽聽聽聽聽聽聽聽聽聽聽 WHEN b.AVERAGE_TASK_COUNT > 0 THEN ((a.AVERAGE_TASK_COUNT - b.AVERAGE_TASK_COUNT) / b.AVERAGE_TASK_COUNT) * 100
聽聽聽聽聽聽聽 END as PERCENT_CHANGE_FROM_PREVIOUS_PERIOD
聽聽聽 FROM averageTasksPerProjectInRange a, averageTasksPerProjectInPreviousRange b
)
SELECT
聽聽聽 a.AVERAGE_TASK_COUNT,
聽聽聽 b.AVERAGE_TASK_COUNT as PREVIOUS_AVERAGE_TASK_COUNT,
聽聽聽 c.CHANGE_FROM_PREVIOUS_PERIOD,
聽聽聽 d.PERCENT_CHANGE_FROM_PREVIOUS_PERIOD
FROM averageTasksPerProjectInRange a, averageTasksPerProjectInPreviousRange b, rawChange c, percentChange d
Troubleshooting
- No results: If your query does not return any results, check to make sure double and single quotations copied correctly.