# View: avod_revenue_views

**View Name:** avod_revenue_views
**Table Source:** `Derived from: Dbt_Prod.Awal_Tier_Groups, Dbt_Prod.Youtube_Ad_Supported_Mrr_Update, Intelligence.Dbt_Prod, Prod.Dim_Release`
**File Path:** `views/yt_performance_report/avod_revenue_views.view.lkml`

## Overview

- **File Size:** 1485 bytes
- **Lines of Code:** 57
- **Dimensions:** 0
- **Measures:** 2
- **Dimension Groups:** 1
- **Filters:** 0

## Measures

| Name | Type |
|------|------|
| `partner_revenue` | sum |
| `owned_views` | sum |

## Dimension Groups

| Name | Type |
|------|------|
| `download_date` | time |

## Derived Table

```sql
sql:
   WITH latest_month AS (
    SELECT DATE_TRUNC('month', MAX(download_date)) AS max_month
    FROM INTELLIGENCE.DBT_PROD.YOUTUBE_AD_SUPPORTED_MRR_UPDATE
)

SELECT
    ad_supported.download_date,
    SUM(ad_supported.partner_revenue) AS partner_revenue,
    SUM(ad_supported.owned_views) AS owned_views
FROM (
    SELECT *
    FROM INTELLIGENCE.DBT_PROD.YOUTUBE_AD_SUPPORTED_MRR_UPDATE,
         latest_month
    WHERE
        download_date >= DATEADD(month, -1, max_month)
        OR download_date = DATEADD(month, -12, max_month)
) AS ad_supported
LEFT JOIN facts.prod.dim_release AS facts_prod_dim_release
    ON CAST(ad_supported.current_upc AS VARCHAR) = CAST(facts_prod_dim_release.releaseid AS VARCHAR)
LEFT JOIN INTELLIGENCE.DBT_PROD.AWAL_TIER_GROUPS AS int_dbt_prod_awal_tier_groups
    ON facts_prod_dim_release.labelid = int_dbt_prod_awal_tier_groups.labelid
WHERE
    (int_dbt_prod_awal_tier_groups.brand_name NOT IN ('awal', 'altafonte')
     OR int_dbt_prod_awal_tier_groups.brand_name IS NULL)
GROUP BY 1
ORDER BY 1 DESC

  ;;
```

