Owner dashboard metrics and SQL for trends by workspace and role
Use these exact definitions to build one owner dashboard. Each metric states its numerator, denominator, time window, exclusions, and SQL. A metric is shipped only when the fields it needs are present on existing records.
What can be computed reliably and what cannot
This page adds no new tracking and collects no new field. Confirm the question records table name and every column name once in migrations/0002_app.sql in the shipped build, then use those names in the SQL below. Field logic does not change when a name is confirmed.
| Metric | Reliably computable | Field needed on existing records | Limit |
|---|---|---|---|
| Questions asked per week per workspace | Yes | tenant_id, submission time, test flag | Count only. Draft writing that was never submitted is not counted. |
| Answered share, unanswered rate, handoff rate | Yes | tenant_id, submission time, test flag, answer outcome, citation presence | An answer with no listed source is not counted as answered. |
| Helpful rate and rating coverage | Yes | tenant_id, answer time, helpful or not helpful rating | Unrated answers stay out of the helpful rate and are shown as a separate count. |
| Time to first answer median | Yes, when both times are stored | tenant_id, question submission time, first sourced answer time, citation presence | When first sourced answer time is not stored, do not ship a median. Do not estimate it from headline counts. Use the bounded count plus middle-rows fetch in Query 3A and 3B below, not a transfer of every answered row. |
| Weekly active users and asker retention | Yes, when signed-in identity is stored | tenant_id, signed-in identity on question record, submission time, test flag | Visitors without an account have no signed-in identity and are counted in questions by channel only. In session-only mode, retention is not calculated. |
| Follow-up share | Yes, when turn order is stored | tenant_id, chat identifier or turn index, submission time | When turn index is not stored, do not ship follow-up share. |
| Reformulation rate | Conditional | tenant_id, turn index, prior answer outcome, prior rating | Ship only when prior outcome and prior rating can be linked for each follow-up. When that link is not stored, do not ship the rate. |
| Trend by role | Conditional | tenant_id, role stored on the question or answer record at the time of the question | Current Team role alone does not prove the role at the time of an earlier question. When only current role is stored, label the split as current role and do not use it for retention or for change over time. |
| Visitor repeat visit | No | None in this pack | No fingerprint, address, or marketing identifier is used for this count. Do not claim a visitor repeat count. |
Exact definitions, numerators, denominators, and time windows
Calculate inside one college workspace at a time for workspace trends. State the college workspace, assistant, channel, start and end dates, and college local time on the dashboard header.
Shared rules for every metric
- Test and staff preview sessions are labeled as test and are excluded from every metric. The excluded count is shown where the screen can count it.
- Unavailable checks are recorded separately as unavailable only when a question record was created. They are not counted as not answered and not counted as a source gap.
- When a denominator is zero, the screen shows no questions in this range, no rated answers in this range, no active users in this range, or no follow-up questions in this range, as fits the metric. It does not show zero percent.
- System view shows totals grouped by college workspace only. It never shows question text and never mixes one college with another.
- In session-only mode, nothing is kept after the session ends, so a metric that needs kept records states not calculated in session-only mode.
Time window and comparison
- A week runs Monday 00:00 to the next Monday 00:00 in college local time. The start date is included and the end of the range is excluded.
- The reporting path passes week start and week end as bounds, converted to the stored time form. A range that includes today is labeled as a partial day.
- The comparison period is the preceding period of the same number of days, with the same workspace, assistant, channel, and exclusions.
- Counts show the change in count. Rates show the change in percentage points. A median shows the change in minutes between the two medians.
Questions asked
Definition: count of submitted question turns in the range for this workspace.
- Numerator and count: one count for each submitted question turn on the Ask screen or the widget, counted at submission time.
- Denominator: none. This is a count, not a rate.
- Channel: show the app count, the widget count, and the total, so app use and widget use are not mixed.
Answered share
Definition: share of questions asked that received an answer with at least one approved source citation.
- Numerator: answers with at least one approved source citation.
- Denominator: questions asked in the same range, workspace, assistant, and channel.
Unanswered rate
Definition: share of questions asked that no approved source covered.
- Numerator: questions recorded as not answered.
- Denominator: questions asked in the same range, workspace, assistant, and channel.
- Difference from answered share: handed off questions are shown separately in the handoff rate and are not added to this rate.
Helpful rate and rating coverage
Definition: share of rated answers marked helpful.
- Numerator: answers rated helpful.
- Denominator: answers rated helpful plus answers rated not helpful. Unrated answers are not in the denominator.
- Coverage: rated answers divided by answered answers, with both counts shown beside the helpful rate.
Time to first answer
Definition: median elapsed time between question submission and first sourced answer, across answered questions in the range.
- Calculation: for each answered question, first sourced answer time minus question submission time, in minutes. The dashboard shows the median with the count of answered questions behind it, using the bounded fetch in Query 3A and 3B below.
- Population: answered questions in the range that hold both times. Not-known messages, handoffs with no sourced answer, and unavailable checks are not in the median.
Weekly active users
Definition: count of distinct signed-in people who asked at least one question in one Monday to Sunday week in this workspace.
- Numerator and count: distinct signed-in identities in the week. A person who asks several questions in the week counts once.
- Denominator for questions per active user: weekly active users for the same range. Show the total question count beside the result.
Asker retention
Definition: share of signed-in askers in a cohort week who ask again in a later week under the same assistant and channel filters.
- Numerator: cohort askers who ask at least one question in the later week chosen on the screen. Week 1 is the week after the cohort week. Week 4 is the fourth week after the cohort week.
- Denominator: distinct signed-in people who asked in the cohort week. Show the cohort size beside every retention rate.
- Difference from data retention: asker retention measures return use. Data retention sets how long records are kept. The screen states both, so the two are not confused.
Follow-up share
Definition: share of questions asked that are follow-up questions in the same chat.
- Numerator: question turns with turn index 2 or more in a chat that already has an answer shown.
- Denominator: questions asked in the same range, workspace, assistant, and channel.
SQL ready to ship for workspace trends
Each workspace query filters by tenant_id and binds the workspace in ?1. The reporting path passes week start in ?2 and week end in ?3, converted to the stored time form. Run the combined Query 1 once per week in the range, plus Queries 2, 3A, 3B, and 4. The dashboard joins the weekly rows into the trend. Use one plain string per prepare call in app code.
Query 1: questions, outcomes, active users, and follow-ups in one scan in one week
SELECT COUNT(*) AS questions_asked,
SUM(CASE WHEN has_citation = 1 THEN 1 ELSE 0 END) AS answered,
SUM(CASE WHEN outcome = 'not_answered' THEN 1 ELSE 0 END) AS not_answered,
SUM(CASE WHEN outcome = 'handed_off' THEN 1 ELSE 0 END) AS handed_off,
COUNT(DISTINCT CASE WHEN user_id IS NOT NULL THEN user_id END) AS weekly_active_users,
SUM(CASE WHEN turn_index >= 2 THEN 1 ELSE 0 END) AS followup_questions
FROM questions
WHERE tenant_id = ?1
AND is_test = 0
AND created_at >= ?2
AND created_at < ?3;
Answered share is answered divided by questions_asked. Unanswered rate is not_answered divided by questions_asked. Handoff rate is handed_off divided by questions_asked. Questions per active user is questions asked by signed-in askers in the same week divided by weekly_active_users from this same query, with both counts shown. Follow-up share is followup_questions divided by questions_asked. Run the followup term only when turn_index is stored on the question record. When turn_index is not stored, remove only that one term from the SELECT list and do not run a second questions query to replace it. When questions_asked is zero, show no questions in this range. This one scan replaces four separate questions scans that read the same week rows for questions asked, for outcomes, for distinct users, and for follow-ups.
Query 2: helpful rate and rating coverage in one week
SELECT SUM(CASE WHEN rating = 'helpful' THEN 1 ELSE 0 END) AS helpful,
SUM(CASE WHEN rating = 'not_helpful' THEN 1 ELSE 0 END) AS not_helpful
FROM answers
WHERE tenant_id = ?1
AND is_test = 0
AND created_at >= ?2
AND created_at < ?3;
Rated answers are helpful plus not_helpful. Helpful rate is helpful divided by rated answers. Rating coverage is rated answers divided by answered from Query 1. When rated answers are zero, show no rated answers in this range.
Replace the old full scan with two queries: a count first, then a fetch of at most 2 middle rows. This reduces payload from N rows to 2 rows per week.
Query 3A: count answered rows for the median first
SELECT COUNT(*) AS n FROM questions WHERE tenant_id = ?1 AND is_test = 0 AND has_citation = 1 AND first_answer_at IS NOT NULL AND created_at >= ?2 AND created_at < ?3;
Bind ?1 to the workspace, ?2 to week start and ?3 to week end in the stored time form. When n is 0, show no answered questions in this range for the median and run no Query 3B. When n is greater than 0, compute offset in code as the integer part of (n minus 1) divided by 2, and bind that offset as ?4 in Query 3B. This replaces the old unbounded Query 3 that transferred created_at and first_answer_at for every answered row in the week and sorted every row in JavaScript.
Query 3B: fetch only the middle rows for the median
SELECT created_at, first_answer_at FROM questions WHERE tenant_id = ?1 AND is_test = 0 AND has_citation = 1 AND first_answer_at IS NOT NULL AND created_at >= ?2 AND created_at < ?3 ORDER BY (julianday(first_answer_at) - julianday(created_at)) ASC, id ASC LIMIT 2 OFFSET ?4;
When n is odd, Query 3B returns 1 row and the median is elapsed minutes for that row. When n is even, Query 3B returns 2 rows and the median is the average of elapsed minutes for the 2 rows. Elapsed minutes for a row is first_answer_at minus created_at, computed in code from the 2 returned timestamps. Show n beside the median, as this guide already requires. The id ascending tie break keeps a page boundary stable, as in List pagination, sorting, and filtering. Confirm the table name, the id column name, and every other column name once in migrations/0002_app.sql in the shipped build, as stated at the top of this page, then use those names in both queries. Use idx_questions_tenant_test_created_cover from the index list below. It covers tenant_id, is_test, created_at, has_citation, and first_answer_at, so the count and the middle-rows fetch answer from the index range for tenant_id, is_test and created_at over the bounded answered set only. Do not use a separate first_answer index, because that index is dropped in the same migration below. Questions with a missing time stay out, and the excluded count is shown where the screen can count it. Payload per week falls from n answered rows to at most 2 rows plus 1 count. No JavaScript sort of every row runs.
- Payload per week falls from n rows to at most 2 rows. No JavaScript sort of every row runs.
- Result matches the old Query 3 result for the same week, workspace, assistant and channel filters, because the order is elapsed time ascending and the offset selects the middle of that order.
- Exclusions stay the same. Test sessions, not-known messages, handoffs with no sourced answer and questions with a missing time stay out, and the excluded count is shown where the screen can count it.
- Confirm the table name and every column name once in migrations/0002_app.sql in the shipped build, as the guide already states, then use those names in both queries. Field logic does not change when a name is confirmed.
Query 4: asker retention for Week 1 or Week 4
WITH cohort AS (
SELECT DISTINCT user_id
FROM questions
WHERE tenant_id = ?1
AND is_test = 0
AND user_id IS NOT NULL
AND created_at >= ?2
AND created_at < ?3
),
later AS (
SELECT DISTINCT user_id
FROM questions
WHERE tenant_id = ?1
AND is_test = 0
AND user_id IS NOT NULL
AND created_at >= ?4
AND created_at < ?5
)
SELECT (SELECT COUNT(*) FROM cohort) AS cohort_askers,
COUNT(later.user_id) AS retained_askers
FROM cohort
LEFT JOIN later ON later.user_id = cohort.user_id;
Asker retention is retained_askers divided by cohort_askers. Use cohort week bounds in ?2 and ?3 and later week bounds in ?4 and ?5, with the same assistant and channel filters in both parts when those filters are chosen. When the cohort count is zero, show no cohort askers in this range.
Before and after: query count, rows transferred, and rows scanned
| Measure, per week, N rows in the week | Before | After |
|---|---|---|
| Prepares for the main cards | 6 prepares: old Queries 1, 2, 3, 4, 5, and 7 | 4 prepares: Queries 1, 2, 3A, and 3B |
| Questions index entries read | About 5 times N: four full week scans plus the median scan | About 2 times N: one combined scan plus the bounded median count and middle-rows fetch over answered rows only |
| Rows transferred for the median | N answered rows per week, sorted in JavaScript | At most 2 rows plus 1 count per week, ordered in the database with no JavaScript sort |
| Example, N = 1000, 13 weeks | About 65000 index entries and 78 prepares | About 26000 index entries and 52 prepares. Saving about 39000 index entries, or 60 percent, and 26 prepares per 13 week trend. Median rows transferred fall from about 13000 answered rows to 26 rows, a 99.8 percent reduction. |
| Secondary indexes maintained on each questions write | 6 on questions: five tenant scoped indexes plus the system view index | 2 on questions: one covering tenant scoped index plus the system view index |
Example only. The arithmetic uses example row counts to show the method. It does not state a measured size for a college workspace in production. The median count and middle-rows fetch stay separate because a median cannot be computed from counts alone, and the answers scan stays separate because ratings live on the answers table.
Indexes required for these queries
Confirm the table name and every column name in migrations/0002_app.sql first. Add the indexes below in a new migrations/01NN file in the app build, and drop the five redundant single purpose questions indexes in that same migration, with IF EXISTS, after the covering index is created. Do not edit migrations/0002_app.sql or migrations/0001_core.sql. Create the covering index only with columns confirmed in migrations/0002_app.sql. Omit a trailing column for a metric that is not shipped, and do not create a separate index for that metric. Each workspace query already filters by tenant_id. Without an index each query full-scans the table and looks up each row. With the covering index the database answers from the index range for tenant_id, is_test and created_at and does not look up the table for the columns these queries read.
CREATE INDEX IF NOT EXISTS idx_questions_tenant_test_created_cover ON questions (tenant_id, is_test, created_at, has_citation, outcome, user_id, turn_index, first_answer_at);
CREATE INDEX IF NOT EXISTS idx_answers_tenant_test_created_rating ON answers (tenant_id, is_test, created_at, rating);
CREATE INDEX IF NOT EXISTS idx_questions_test_created_tenant ON questions (is_test, created_at, tenant_id, has_citation);
DROP INDEX IF EXISTS idx_questions_tenant_test_created;
DROP INDEX IF EXISTS idx_questions_tenant_test_created_outcome;
DROP INDEX IF EXISTS idx_questions_tenant_test_created_user;
DROP INDEX IF EXISTS idx_questions_tenant_test_created_turn;
DROP INDEX IF EXISTS idx_questions_tenant_test_created_first_answer;
- Query 1, Query 3A, Query 3B, and Query 4 use idx_questions_tenant_test_created_cover, which covers has_citation, outcome, user_id, turn_index, and first_answer_at. The old shorter idx_questions_tenant_test_created was a prefix of every other questions index, so the planner could already use a longer index for those queries and the shorter index only added write and storage cost. Query 3B orders by elapsed time over that bounded answered set only and transfers at most 2 rows.
- Query 2 uses idx_answers_tenant_test_created_rating, which covers rating.
- The system view queries in Reports use idx_questions_test_created_tenant, because those queries have no tenant_id filter and group by tenant_id. Run those queries only in the system governance reporting path.
- Each query is a bounded index range scan for its week. The combined Query 1 reads the week rows once for four main cards instead of four times. Query 3A reads only a count and Query 3B reads only the middle rows, instead of every answered row. No query reads a row outside its tenant_id, is_test and created_at range, and no query is run once per row. The per week loop is sequential prepares, and the combined query plus the bounded median cut that loop for the main cards from six prepares to four per week while bounding transferred rows.
- The trend by role query below adds role to the group. Add role as the last column of idx_questions_tenant_test_created_cover only when role is stored on the question record at the time of the question and the role split is shipped. Do not create a second questions index for the role split.
Trend by role, with the guard that keeps it honest
Role trends are useful only when the role on the record is the role at the time of the question. Ship the split below only under that condition.
SELECT role,
COUNT(*) AS questions_asked,
SUM(CASE WHEN has_citation = 1 THEN 1 ELSE 0 END) AS answered
FROM questions
WHERE tenant_id = ?1
AND is_test = 0
AND created_at >= ?2
AND created_at < ?3
GROUP BY role
ORDER BY questions_asked DESC;
- Answered share for a role is answered divided by questions_asked for that role, with both counts shown for that role.
- When role is not stored on the record, do not run this query as a trend. A current Team role split may be shown only as a labeled current role view, and it must not be used for retention or for change over time.
- System view never shows a role split and never joins people across colleges. Role splits stay inside one college workspace.
- Reading full question text for a role split needs the separate detail permission and is audit logged, as stated on Reports.
Dashboard layout to ship
- Place the cards below the filter row for college workspace, assistant, channel, and date range. State the workspace, assistant, channel, start and end dates, and college local time on the header.
- Show cards in this order: questions asked, answered share, unanswered rate, helpful rate, time to first answer, weekly active users, asker retention, follow-up share.
- Show the trend as one row per week with the week start date, so a change from week to week is read from the table and not from a chart alone.
- Make each card a link to the filtered list behind it, with the same filters applied. Show the current value, the comparison value, and the change.
- Do not show a target or benchmark. Do not show a rate without its numerator and denominator counts.
Worked example, labeled example only
The rows below use example counts only. They show the arithmetic. They are not results for any college.
| Example workspace | Questions asked | Answered | Handed off | Not answered | Answered share | Unanswered rate | Helpful of rated | Helpful rate |
|---|---|---|---|---|---|---|---|---|
| Example workspace A | 200 | 160 | 25 | 15 | 160 of 200, 80.0 percent | 15 of 200, 7.5 percent | 80 of 100 | 80.0 percent |
| Example workspace B | 120 | 72 | 18 | 30 | 72 of 120, 60.0 percent | 30 of 120, 25.0 percent | 36 of 60 | 60.0 percent |
Checks before you ship the dashboard
Run each check in a test college workspace. If a check fails, fix it before you publish the dashboard.
- Table and column names in the SQL match migrations/0002_app.sql in the shipped build, and every workspace query filters by tenant_id.
- The indexes in the indexes section above are present in a new 01NN migration, the indexes match the confirmed table and column names, the five dropped indexes are absent after the migration, and Query 3A returns only a count while Query 3B returns at most 2 rows with created_at and first_answer_at, ordered by elapsed time with an id tie break.
- For a week with 0 answered questions, Query 3A returns 0, Query 3B does not run, and the screen shows no answered questions in this range for the median, not zero minutes.
- For a week with an odd answered count, Query 3B returns 1 row. For an even count, Query 3B returns 2 rows. The median from those rows matches the median from the old unbounded Query 3 rows for the same week, workspace, assistant and channel filters.
- Rows transferred per week for the median fall from n answered rows to at most 2 rows plus 1 count, and no JavaScript sort of every row runs.
- The test flag excludes test sessions from every metric and the excluded count is shown.
- A zero denominator shows the stated words for that metric and does not show zero percent.
- Session-only mode shows not calculated in session-only mode for metrics that need kept records.
- Unavailable checks are shown separately and are not counted as not answered.
- Role split runs only when role is stored on the record. When only current role is stored, the screen labels the split as current role.
- Reformulation rate and follow-up share run only when turn index and prior outcome can be linked. When that link is not stored, those cards are not shown.
- Each card opens the filtered list behind it with the same workspace, assistant, channel, and date range.
- Reading full question text and exporting detail need the separate detail permission and are audit logged.
Follow Read reports for the list behind a number, Work unanswered questions to assign an owner for unanswered and reformulated questions, and Set retention and access before a college moves to session-only mode.
Next guide
Read the numbers, then work the largest gap first.