Interactive Web Q&A Powered by a Single Source of Truth

    Learn how to turn a static business-data page into a reliable, shareable interactive workspace. This article explains how to keep charts, tables, and natural-language answers aligned with the same loaded dataset through deterministic filtering and aggregation, structured query generation, explicit time rules, versioning, access control, and regression testing.

    A business data page often ends up being “viewable but not askable.” The charts look polished, but their definitions are fixed. As soon as a user changes the date range or dimension, the page can no longer answer the question.

    An earlier approach was to provide documentation to a conversational system and let it generate a response. The answers might sound more complete, but users would first need access to the same materials and tools, which increases the cost of adoption.

    A better approach is to combine visualization and Q&A into a shareable page. Charts, tables, and answers should all depend on the same dataset actually loaded by the page. When the data changes, the visualizations and answers should change together.

    1. Where the Problem Comes From

    Preset questions are essentially presentation scripts. When a user clicks “How are online channels performing?”, the system returns a prewritten conclusion. It may look like a calculation, but it is usually just retrieving copy.

    If the user changes the question to “How did online channels perform during the first ten days of July?”, three conditions change at once: time, channel, and metric. The script no longer matches, so the system appears unable to understand the question.

    This means the interaction is connected to wording rather than data. Reliable page-level Q&A should satisfy at least four requirements:

    • Answers must be traceable to the records currently loaded, rather than model memory or outdated copy.
    • Filters must be composable, especially for date ranges, categories, regions, and metrics.
    • After the source data changes, charts and answers must use the same version. The page must not show new charts with old explanations.
    • When a question exceeds what the data can answer, the system must clearly refuse or explain the limitation instead of filling the gap with fluent text.

    The user experience should also be simple: anyone with the link should be able to open the page without installing a workspace or understanding knowledge-base configuration.

    2. Use One Dataset as the Single Source of Truth

    Start by organizing business records into a spreadsheet or another equivalent structured format. Typical fields might include sales date, channel, region, product, quantity, and amount.

    Do not manually maintain a second set of statistical results in the page. When the page loads, a script should read the source data and perform three steps:

    1. Validate field types and required fields. Invalid rows should be recorded in a separate data-quality notice rather than included in totals.
    2. Generate the aggregations required by the page, such as totals by channel, daily trends, and regional shares.
    3. Pass the same records to the Q&A module as the only dataset that answers may reference.

    A minimal structure might look like this:

    1. date,channel,region,product,qty,amount
    2. 2024-07-03,online,east,A,12,3600
    3. 2024-07-08,store,east,A,4,1280

    The page should perform deterministic operations only: filtering, grouping, summing, counting, averaging, calculating shares, and selecting comparison periods for year-over-year analysis. These rules are fixed and can be checked independently.

    Natural language should only translate a user’s question into instructions such as which rows to select, how to group them, and which metric to calculate. It should not calculate amounts mentally.

    If a user changes one row in the spreadsheet and republishes or reloads the data, the bar chart, detail table, and answer to a question such as “What were online sales during the first ten days of July?” should all change accordingly. The HTML page is not becoming a separate system; it remains a view of the data.

    3. Generate Executable Queries Before Writing Answers

    The interaction area can still provide several example questions, but examples should be entry points to query templates, not cached answers.

    A recommended processing flow is:

    • Parse the intent: identify the time range, dimensions, metrics, comparison relationship, and sorting requirements.
    • Apply a whitelist: allow only declared fields and aggregation functions. If a term cannot be mapped, return a message such as “The current dataset does not contain that field.”
    • Generate filters: convert phrases such as “the first ten days of July” into an explicit date interval. The response should state the actual start and end dates so that the interpretation is clear.
    • Execute the query: run it in the browser or in the calculation service connected to the page, producing a tabular result.
    • Write a short response: provide the numbers and definitions first, followed by a comparison when applicable. Do not state conclusions that were not calculated.

    The question “How are online channels performing?” could be expanded into the following query:

    • Filter: channel = online
    • Time range: the full available period by default
    • Metrics: amount, quantity, and the share of total amount
    • Optional result: a daily trend, but only if the loaded sample can support it

    Adding “during the first ten days of July” should add only a date filter. It should not send the request through a separate hard-coded branch.

    Time expressions require explicit rules. Terms such as “early in the month,” “mid-month,” “late in the month,” “this week,” “the last seven days,” and “as of a given date” should define:

    • The time zone
    • Whether the end date is inclusive
    • How to respond when the latest available record predates the requested date

    Once these rules are built into the page, both example questions and free-form input can use them. Otherwise, a question selected from a menu may work while an equivalent question typed by the user fails.

    4. Keep the Model and the Data in Separate Roles

    If a language model is used to understand questions, restrict it to the translation layer. It may see field descriptions and a small number of sample values to map synonyms such as “online,” “web store,” and “online channel.”

    However, it should not freely receive the entire table, generate an answer, and have that answer treated as authoritative. A safer response from the model is a structured query containing dimensions, filters, metrics, and aggregations. Local application logic then executes the query.

    A fixed four-part answer template can further reduce hallucinations:

    • Scope: time range, filters, and number of matching records
    • Result: metric values and units
    • Comparison: only when the comparison subset also exists in the dataset
    • Limits: whether the sample is empty, dates are missing, or the result can be extrapolated

    For an empty result, say “There are 0 records under these conditions.” Do not silently recommend another channel unless the user explicitly asks to broaden the conditions.

    Questions about complaints, policies, opening hours, or other information outside the table should be handled separately. Data questions should use calculations over the dataset. Policy questions should use separately maintained explanatory content with a clear source reference. The two types of answers should not be blended into one response that merely sounds knowledgeable.

    5. Publishing, Synchronization, and Versioning

    “One-click publishing” solves access, not consistency. A minimum viable release should include the following:

    • Publish the page and data file together, or have the page retrieve data by version number.
    • Display the data update time and record count in a response header or page footer so users can identify which version they are viewing.
    • When the data file changes, chart configuration should not need to be rewritten. If fields are added or removed, update the field whitelist; otherwise, new columns cannot be queried and deleted columns may still be requested.

    The synchronization strategy should be decided in advance. Overwriting the current release is simple and suitable for internal sharing. If several people edit the data, retain version numbers and attach the version to Q&A results. This prevents screenshots and live figures from being compared across different definitions.

    Large tables do not need to render all detail rows at once. Detail data can be paginated, but aggregations must still run over the full set of records that match the filters. The interface should state clearly that only the first several detail rows are displayed while totals are based on all matching records.

    For data containing personal or transaction-level details, do not publish a completely public link. Access controls can expose only aggregated results, or sensitive fields can be masked before export. If question logs are stored, make sure they do not write transaction details into uncontrolled conversation records.

    6. How to Verify That the Page Can Really Answer Questions

    Before release, run regression tests against a fixed sample dataset rather than judging the page only by the appearance of its charts. At a minimum, test the following:

    • Change one amount and verify that the corresponding total changes by exactly the same amount.
    • Confirm that an example question and an equivalent manually reworded question return the same result.
    • Narrow a full-month query to the first ten days, verify that the number of matching rows decreases, and manually check the amount.
    • For nonexistent fields, future dates, and empty channels, return a refusal or zero-result response instead of inventing a share.
    • Roll the data file back to an older version and verify that both the page version shown in the footer and the figures return to the older definition.

    These checks turn the idea that “the answer sounds like it came from an employee” into something verifiable. Polite language is a user-experience concern. Whether the numbers come from the current table is what determines whether the page can replace follow-up questions.

    7. Practical Trade-Offs

    Calculating everything in the browser simplifies deployment and keeps the data within the page context. This approach is suitable for small tables and aggregated data that can be shared publicly.

    When the table is large or definitions must be centrally audited, the same filtering and aggregation logic should run on the server. The page should submit only controlled queries. In either architecture, the model must not bypass the aggregation layer and report numbers directly.

    Field definitions should be written for both people and parsers. Document the standard channel values, whether amounts include tax, and whether the date represents order time or payment time. Without this contract, interactive Q&A only makes ambiguous questions sound more precise.

    A successful page should let readers do three things:

    1. View predefined charts.
    2. Recalculate results using their own conditions.
    3. Check the metric definitions and data version.

    When these requirements are met, static HTML is no longer a one-time presentation. It becomes an interactive workspace whose visualizations and answers stay synchronized with the underlying data.