# Views

BI Views are logical representations of data obtained from underlying queries. Where queries represent particular facts within a data source, views represent answers to particular questions. For example, you may have a query definition for "Patients", however a view for "Patients By Gender By Age".&#x20;

Views allow you to:

1. Aggregate data from queries using a common database independent syntax&#x20;
2. Pivot data from queries using defined buckets / columns
3. Further filter queries based on a sub-set of data

### View Definition Files

View definition files are defined using the BiViewDeifnition root.

```markup
<?xml version="1.0"?>
<BiViewDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="by-type-date" id="org.santedb.bi.core.view.session.type" xmlns="http://santedb.org/bi">
  <meta status="active">
    <authors>
      <add>SanteSuite Contributors</add>
    </authors>
  </meta>
  <query ref="#org.santedb.bi.core.query.session" />
  <aggregations>
    <add>
      <providers>
        <invariant>psql</invariant>
      </providers>
      <grouping>
        <column name="crt_utc">cast(crt_utc as DATE)</column>
        <column name="ses_typ">ses_typ</column>
      </grouping>
      <select>
        <column name="ses_typ" fn="value">ses_typ</column>
        <column name="ses_date" fn="value">cast(crt_utc as DATE)</column>
        <column name="n_sessions" fn="count-distinct">ses_id</column>
      </select>
    </add>
  </aggregations>
  <pivot key="ses_date" columnDef="ses_typ" value="n_sessions" fn="sum" />
</BiViewDefinition>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.santesuite.org/developers/applets/business-intelligence-bi-assets/bi-asset-definitions/views.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
