# View: dt_etl_monitor_accounting

**View Name:** dt_etl_monitor_accounting
**Table Source:** `Derived from: Bi.Accounting_Aggregates, Prod.Workstation_Fact_Sales_Unified_Dbt, Royalty_Accounting, Royalty_Accounting.Prod`
**File Path:** `dt_etl_monitor_accounting.view.lkml`

## Overview

- **File Size:** 3537 bytes
- **Lines of Code:** 155
- **Dimensions:** 9
- **Measures:** 7
- **Dimension Groups:** 0
- **Filters:** 0

## Dimensions

| Name | Type |
|------|------|
| `fs_type` | string |
| `fs_accounting_date` | date |
| `fs_storeid` | number |
| `a_type` | string |
| `a_accounting_date` | date |
| `a_storeid` | number |
| `agg_type` | string |
| `agg_accounting_date` | date |
| `agg_storeid` | number |

## Measures

| Name | Type |
|------|------|
| `count` | count |
| `total_fs_rows` | sum |
| `fs_gross_rev` | sum |
| `total_accounting_rows` | sum |
| `a_gross_rev` | sum |
| `total_agg_rows` | sum |
| `agg_gross_rev` | sum |

## Derived Table

```sql
sql:
SELECT *
FROM (
    SELECT
        'fact_sales' AS fs_type,
        date_from_parts(accountingyear, accountingmonth, 01) AS fs_accounting_date,
        storeid AS fs_storeid,
        COUNT(*) AS total_fs_rows,
        SUM(gross) AS fs_gross_rev
    FROM royalty_accounting.prod.workstation_fact_sales_unified_dbt
    WHERE fs_accounting_date >= '2016-08-01'
    GROUP BY 1, 2,3
) fs
    LEFT JOIN (
        SELECT
            'bi_accounting' AS a_type,
            accounting_month AS a_accounting_date,
            storeid AS a_storeid,
            COUNT(*) AS total_accounting_rows,
            SUM(gross_revenue_usd) AS a_gross_rev
        FROM prod.bi.accounting
        WHERE a_accounting_date >= '2016-08-01'
        GROUP BY 1,2,3
    ) a ON fs.fs_accounting_date = a.a_accounting_date AND fs.fs_storeid = a.a_storeid
    LEFT JOIN (
        SELECT
            'bi_accounting_agg' AS agg_type,
            accounting_month AS agg_accounting_date,
            storeid AS agg_storeid,
            COUNT(*) AS total_agg_rows,
            SUM(gross_revenue_usd) AS agg_gross_rev
        FROM prod.bi.accounting_aggregates
        WHERE agg_accounting_date >= '2016-08-01'
            AND aggregate = 'Label Level'
        GROUP BY 1,2,3
    ) agg ON fs.fs_accounting_date = agg.agg_accounting_date AND fs.fs_storeid = agg.agg_storeid ;;
```

