# View: cm_non_traditional_charts

**View Name:** cm_non_traditional_charts
**Table Source:** `INTELLIGENCE.DBT_PROD.CM_NON_TRADITIONAL_CHARTS`
**File Path:** `cm_non_traditional_charts.view.lkml`

## Overview

- **File Size:** 3567 bytes
- **Lines of Code:** 135
- **Dimensions:** 8
- **Measures:** 3
- **Dimension Groups:** 1
- **Filters:** 0

## Comments & Notes

- derived_table: {
- sql: with chart1 as (
- #     select tiktok as "ID_NUMERIC", null as "ID_STRING", 'TikTok' as "STORE",

## Dimensions

| Name | Type |
|------|------|
| `id_numeric` | number |
| `id_string` | string |
| `store` | string |
| `chart_type` | string |
| `country` | string |
| `isrc` | string |
| `artist` | string |
| `track` | string |

## Measures

| Name | Type |
|------|------|
| `rank` | number |
| `rank2` | number |
| `rank_change` | number |

## Dimension Groups

| Name | Type |
|------|------|
| `chart` | time |

## Derived Table

```sql
#   sql: with chart1 as (
#
  #     select tiktok as "ID_NUMERIC", null as "ID_STRING", 'TikTok' as "STORE",
  #    tc.timestp, 'GLOBAL' as "COUNTRY",
  #   'TikTok Weekly' as "CHART_TYPE", rank, t.isrc, t.track as "TRACK", t.artist as "ARTIST"
  #    from CHARTMETRIC.RAW_DATA.TIKTOK_WEEKLY_POST_CHART tc
  #    left join CHARTMETRIC.RAW_DATA.TIKTOK  t on tc.tiktok = t.id
#
  #     union all
#
  #     Select  null as "ID_NUMERIC", youtube as "ID_STRING",
  #    'YouTube' as "STORE", timestp, country, 'YouTube Weekly Track' as "CHART_TYPE",
  #   position as "RANK", isrc, y.track_title||y.title as "TRACK", y.artist_name as "ARTIST"
  #    from CHARTMETRIC.RAW_DATA.YOUTUBE_TRACK_CHART yt
  #    left join CHARTMETRIC.RAW_DATA.YOUTUBE y on yt.youtube = y.id
  #    where y.track_title||y.title is not null
#
#
  #     union all
#
  #     Select  null as "ID_NUMERIC", youtube as "ID_STRING",
  #    'YouTube' as "STORE", timestp, country, 'YouTube Weekly Video' as "CHART_TYPE",
  #   position as "RANK", isrc, y.track_title||y.title as "TRACK", y.artist_name as "ARTIST"
  #    from CHARTMETRIC.RAW_DATA.YOUTUBE_VIDEO_CHART yv
  #    left join CHARTMETRIC.RAW_DATA.YOUTUBE y on yv.youtube = y.id
  #    where y.track_title||y.title is not null),
#
  #     chart2 as (
  #    select *
  #   from chart1)
#
  #     select c1.id_numeric, c1.id_string, c1.store, c1.timestp as date1, c2.timestp as date2, c1.country as country1, c2.country as country2,
  #    c1.chart_type as charttype1, c2.chart_type as charttype2, c1.rank as rank1, c2.rank as rank2, c1.isrc as isrc1, c2.isrc as isrc2, c1.artist, c1.track
  #   from chart1 c1
  #    left outer join chart2 c2 on c1.isrc = c2.isrc and c1.chart_type = c2.chart_type and c1.country = c2.country
  #    and to_date(c2.timestp) = dateadd(day,-7,to_date(c1.timestp))
  #    where c1.store in ('YouTube', 'TikTok');;
  #
```

