Generating metrics automatically

Preview Metrics define business logic that answers data questions consistently across conversations. You can generate metrics automatically from your data and semantic model.

This feature is a Technology Preview feature in watsonx BI. Technology Preview offers customers early access to product features, allowing them to explore functionality and share feedback during development. These features are provided for evaluation purposes and might not be fully functional or complete.

Overview

Watsonx BI analyzes your data and semantic data model to create metrics that reflect real business logic.

You can generate metrics automatically by providing a business question that needs to be answered and the corresponding SQL query.

Providing a question and SQL pair anchors metric generation in a real business scenario, which improves both accuracy and relevance. The SQL defines the exact logic used to answer the question, while the question captures the analytical intent. Together, they remove ambiguity in how metrics are created.

This approach to generating metrics allows Data analysts to generate metrics without relying on manual or advanced modeling techniques. Instead of defining relationships, calculations, and the semantic data model manually, watsonx BI extracts these elements directly from the SQL.

By validating the SQL against the data, watsonx BI ensures that generated metrics align with the actual data structure and values. This validation reduces errors and increases trust in metric outputs.

Watsonx BI also identifies additional relevant columns and relationships that can strengthen the answer. As a result, generated metrics are more complete, context-aware, and better suited for answering questions in conversations.

Steps to generate metrics

To generate metrics automatically using this approach, follow these steps.

  1. On the Data and Metrics tab, select a project or create a new one by clicking the '+' button next to the project list.

  2. Click Create metrics.

  3. Enter a unique name for the semantic data model.

  4. Select your data.

  5. Click Next to continue to Metadata enrichment.

    During metadata enrichment, business context-based metadata is added to your data to prepare it for use in conversations and metrics.

    No changes are made to your original data during enrichment.

  6. Click Next after enrichment completes to go to the Metrics overview page.

  7. Click Generate metrics.

  8. Enter a business question and corresponding SQL query, then click Generate.

    • Watsonx BI validates the SQL against the dataset

    • One or more metrics are generated to answer the question

    • Additional relevant columns and relationships are included automatically

  9. Review the metrics generated from your questions and SQL queries, then select the ones you want to add to the project.

    You can also view any questions and SQL queries that could not be used to generate metrics. You can review the reasons and update your inputs.

  10. The selected metrics display on the Metrics overview page.

    You can now try each metric in a conversation to confirm it answers your data question.

    You can also do the following:

Limitations

  • The business question and SQL are not validated against each other.

  • SQL query must match identifiers in the semantic data model.

  • Results depend on the clarity of the questions and SQL queries. Ambiguous questions or poorly structured SQL might lead to weak or inaccurate metrics.

Troubleshooting metric generation

SQL identifiers do not match identifiers in semantic data model

For metric generation to work correctly, the table names and column names in the SQL must match the identifiers that are in the semantic data model.

If column or table names contain spaces, they are typically converted to underscore-separated names (for example, order date becomes order_date). If identifiers do not match, SQL validation can fail or metrics might not be generated correctly.

You can use the Advanced mode to view the system-generated SQL with the correct identifiers.

  1. Open the semantic data model in Advanced mode.

  2. Right-click a table.

  3. Select Show query information.

This option displays a simple SELECT statement that includes the table and column identifiers in the correct format. You can use this SQL as a reference when building your question–SQL pair. This method is especially useful for uploaded files.

Generating metrics in Advanced mode

You can generate additional metrics after the initial generation by using the Advanced mode.

  1. Open the Advanced mode from the Metrics overview page.

  2. Select the measures that you want to use, right-click, and select Generate metric definitions.

    New metric definitions are generated and displayed in the semantic data model.

  3. Save the semantic data model.

  4. Export the metric definitions that you want to use in conversations.

  5. Go to the Metrics overview page if you want to:

    • Add visualizations to the newly-created metrics

    • Try a metric in a conversation

    • Publish the metrics and related visualizations to the Metrics catalog (Data analysts only)

  6. Go to Navigation menu > Home > Conversations to ask questions about your data.