# View: cpm

**View Name:** cpm
**Table Source:** `Derived from: Latest_Month, Prod.Fact_Youtube_Video_Analytics`
**File Path:** `views/yt_performance_report/cpm.view.lkml`

## Overview

- **File Size:** 752 bytes
- **Lines of Code:** 36
- **Dimensions:** 0
- **Measures:** 1
- **Dimension Groups:** 1
- **Filters:** 0

## Measures

| Name | Type |
|------|------|
| `estimated_cpm` | sum |

## Dimension Groups

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

## Derived Table

```sql
sql:
  WITH latest_month AS (
  SELECT
    DATE_TRUNC('month', MAX(download_activity_date)) AS max_month
  FROM facts.prod.fact_youtube_video_analytics
)

SELECT
  DATE_TRUNC('month', download_activity_date) AS download_date,
  AVG(estimated_cpm) AS estimated_cpm
FROM facts.prod.fact_youtube_video_analytics
WHERE DATE_TRUNC('month', download_activity_date) = (SELECT max_month FROM latest_month)
GROUP BY 1
ORDER BY 1 DESC
;;
```

