Build a Snowflake Cortex Analyst Semantic Model for Finance

Build a finance semantic model for Snowflake Cortex Analyst with DataGalaxy using sample questions, tables, YAML, and queries.

3 min read

This finance proof of concept, built on a Snowflake tutorial, shows a semantic model for Snowflake Cortex Analyst end to end: the business concepts defined in DataGalaxy, the tables they map to, the YAML that describes them, and the natural language questions the finished model can answer.

To learn the general method first, see Build a Semantic Model for Snowflake Cortex Analyst with DataGalaxy.

What kind of questions does this model answer?

With a semantic model in place, Cortex Analyst can interpret questions such as:

  • "What are the new 2022 clients who had upsells in 2023 and then in 2024?"
  • "What are the invoices from 2024 with services from previous years?"

Questions like these need a logical mapping of dimensions, time fields and relationships across several data sources.

Which physical tables are involved?

Four physical tables from Snowflake make up this proof of concept:

  • dim_customer: customer dimension
  • dim_invoice: invoice header data
  • dim_invoice_line: line items in each invoice
  • fact_tracking_arr: fact table for ARR (annual recurring revenue) tracking

How are those tables described in YAML?

The snippet below is the opening of the semantic model YAML file.

name: Finance
description: Semantic model for finance-related queries

tables:
  - name: customer
    description: Customer information
    base_table:
      database: cortex_analyst_finance_poc
      schema: finance
      table: dim_customer
    dimensions:
      - name: customer_id
        description: Unique customer identifier
        expr: customerid
        data_type: text
        unique: true

This defines a logical table named customer, maps it to the physical table dim_customer, and identifies customer_id as a key dimension with a unique constraint.

What happens when you ask a question?

Animation: asking questions in Cortex Analyst. (Re-add this image here — the original Freshdesk link expires after a few days.)

Once the model is deployed, users can query it in natural language.

Example 1: Unpaid invoices in December 2024

Ask: "Which invoices issued in December 2024 are still unpaid?"

Cortex Analyst generates a SQL query from the model's logical-to-physical mappings, identifies the invoices issued in December 2024 and filters for those with a payment status of Unpaid.

Example 2: Revenue from services only

Ask: "What is the revenue from services only?"

The model applies the matching measure and the filters defined for it (for example, filtering by service type), and returns the revenue figure.

Which tools help you go faster?

  • Snowflake documentation: refer to the official Snowflake Cortex Analyst specification for detailed model definitions.
  • YAML generator: use Snowflake's semantic model generator to speed up YAML creation.
  • Streamlit template app: explore the Streamlit app template in Snowflake's Cortex Analyst tutorial for quick integration and testing.

What can you take from this example?

Combining DataGalaxy with Snowflake Cortex Analyst produces a semantic model that supports meaningful, business-driven analysis. Defining dimensions, measures and relationships in YAML is what makes accurate, intuitive natural language queries possible for end users.

Some manual work remains, for joins and synonyms in particular, but DataGalaxy's glossary and lineage tools shorten the setup considerably. Use this example as a reference for building your own semantic models in other business domains.

Read more

Related articles

Was this page helpful?