view: cm_social_current { sql_table_name: INTELLIGENCE.DBT_PROD.CM_SOCIAL_CURRENT ;; # derived_table: { # sql: with current_socials as ( # #select a.name as name, s.account_id as account_id, max(ig_followers) as current_ig_followers, max(fb_likes) as current_fb_likes, #max(tw_followers) as current_tw_followers, max(tt_followers) as current_tiktok_followers, max(yt_views) as current_youtube_views #from INTELLIGENCE.DBT_PROD.CM_SOCIAL_UNION s #left join chartmetric.raw_data.cm_artist a on a.id = s.target_id #where s.target = 'cm_artist' #and to_date(timestp) >= (current_date - 4) #group by 2,1), # #past_socials as ( # #select a.name as name2, s.account_id as account_id2, nullifzero(max(ig_followers)) as past_ig_followers,nullifzero(max(fb_likes)) as past_fb_likes, #nullifzero(max(tw_followers)) as past_tw_followers, nullifzero(max(tt_followers)) as past_tiktok_followers, nullifzero(max(yt_views)) as past_youtube_views #from INTELLIGENCE.DBT_PROD.CM_SOCIAL_UNION s #left join chartmetric.raw_data.cm_artist a on a.id = s.target_id #where s.target = 'cm_artist' #and to_date(timestp) <= (current_date - 8) and to_date(timestp) >= (current_date - 12) #group by 2,1) # #select name as name, account_id as account_id, current_ig_followers, ((current_ig_followers - past_ig_followers)/past_ig_followers) as ig_follower_change, #current_fb_likes, ((current_fb_likes - past_fb_likes)/past_fb_likes) as fb_likes_change, #current_tw_followers, ((current_tw_followers - past_tw_followers)/past_tw_followers) as tw_followers_change, #current_tiktok_followers, ((current_tiktok_followers - past_tiktok_followers)/past_tiktok_followers) as tiktok_followers_change, #current_youtube_views, ((current_youtube_views - past_youtube_views)/past_youtube_views) as youtube_views_change #from current_socials cs #left join past_socials ps on cs.name = ps.name2 and cs.account_id = ps.account_id2 #group by 2,1,3,4,5,6,7,8,9,10,11,12;; # } dimension: name { label: "Artist Name" type: string hidden: yes sql: ${TABLE}.name ;; } dimension: account_id { type: string hidden: yes sql: ${TABLE}.account_id;; } measure: current_ig_followers { label: "Current Instagram Followers" type: max hidden: no sql: ${TABLE}.current_ig_followers;; view_label: "Socials" } measure: ig_follower_change { label: "Instagram Followers Weekly Change" type: max hidden: no sql: ${TABLE}.ig_follower_change;; view_label: "Socials" value_format: "0.00%" } measure: current_fb_likes { label: "Current Facebook Likes" type: max hidden: no sql: ${TABLE}.current_fb_likes;; view_label: "Socials" } measure: fb_likes_change { label: "Facebook Likes Weekly Change" type: max hidden: no sql: ${TABLE}.fb_likes_change;; view_label: "Socials" value_format: "0.00%" } measure: current_tw_followers { label: "Current Twitter Followers" type: max hidden: no sql: ${TABLE}.current_tw_followers;; view_label: "Socials" } measure: tw_followers_change { label: "Twitter Followers Weekly Change" type: max hidden: no sql: ${TABLE}.tw_followers_change;; view_label: "Socials" value_format: "0.00%" } measure: current_tiktok_followers { label: "Current TikTok Followers" type: max hidden: no sql: ${TABLE}.current_tiktok_followers;; view_label: "Socials" } measure: tiktok_followers_change { label: "TikTok Followers Weekly Change" type: max hidden: no sql: ${TABLE}.tiktok_followers_change;; view_label: "Socials" value_format: "0.00%" } measure: current_youtube_views { label: "Current YouTube Views" type: max hidden: no sql: ${TABLE}.current_youtube_views;; view_label: "Socials" } measure: youtube_views_change { label: "YouTube Views Weekly Change" type: max hidden: no sql: ${TABLE}.youtube_views_change;; view_label: "Socials" value_format: "0.00%" } }