diff --git a/bq.block_group_facts.view.lkml b/bq.block_group_facts.view.lkml deleted file mode 100644 index df90ff8..0000000 --- a/bq.block_group_facts.view.lkml +++ /dev/null @@ -1,223 +0,0 @@ -view: bq_block_group_facts { - sql_table_name: `looker-datablocks.acs_fast_facts.fast_facts` ;; - - dimension: logrecno_bg_map_block_group { - hidden: yes - type: string - sql: ${TABLE}.logrecno_bg_map_block_group ;; - primary_key: yes - } - - measure: total_population { - description: "Total Population" - type: sum - sql: ${TABLE}.total_population ;; - } - - # Household Measures - measure: housing_units { - type: sum - group_label: "Households" - sql: ${TABLE}.housing_units ;; - } - measure: avg_persons_house { - type: number - group_label: "Households" - label: "Average Persons per Household" - sql: ${total_population}/NULLIF(${housing_units}, 0) ;; - value_format_name: decimal_2 - } - - # Income Measure - measure: aggregate_income { - hidden: yes - type: sum - group_label: "Households" - sql: ${TABLE}.aggregate_income ;; - } - - measure: avg_income_house { - type: number - group_label: "Households" - label: "Average Income per Household" - sql: ${aggregate_income}/NULLIF(${housing_units}, 0) ;; - value_format_name: usd_0 - } - - # Sex Measures - measure: female_population { - type: sum - sql: ${TABLE}.female ;; - group_label: "Sex" - } - measure: male_population { - type: sum - sql: ${TABLE}.male ;; - group_label: "Sex" - } - measure: pct_male{ - type: number - label: "Male % of Population" - group_label: "Sex" - sql: ${male_population}/NULLIF(${total_population}, 0) ;; - value_format_name: percent_2 - } - measure: pct_female{ - type: number - label: "Female % of Population" - group_label: "Sex" - sql: ${female_population}/NULLIF(${total_population}, 0) ;; - value_format_name: percent_2 - } - - # Racial Measures - - measure: white_alone_or_in_combo { - label: "White Population (Alone or in Combo with Other Races)" - group_label: "Race" - type: sum - sql: ${TABLE}.white_alone_or_in_combo ;; - } - measure: black_alone_or_in_combo { - label: "Black or African American Population (Alone or in Combo with Other Races)" - group_label: "Race" - type: sum - sql: ${TABLE}.black_alone_or_in_combo ;; - } - measure: amind_alone_or_in_combo { - label: "American Indian or Native Alaskan Population (Alone or in Combo with Other Races)" - group_label: "Race" - type: sum - sql: ${TABLE}.amind_alone_or_in_combo ;; - } - measure: asian_alone_or_in_combo { - label: "Asian Population (Alone or in Combo with Other Races)" - group_label: "Race" - type: sum - sql: ${TABLE}.asian_alone_or_in_combo ;; - } - measure: nat_haw_alone_or_in_combo { - label: "Native Hawaiian or Other Pacific Islander (Alone or in Combo with Other Races)" - group_label: "Race" - type: sum - sql: ${TABLE}.nat_haw_alone_or_in_combo ;; - } - measure: white_non_hisp { - label: "White, Non-Hispanic Population" - group_label: "Race" - type: sum - sql: ${TABLE}.white_non_hisp ;; - } - measure: pct_white { - label: "White % of Population" - group_label: "Race" - type: number - value_format_name: percent_2 - sql: ${white_alone_or_in_combo}/NULLIF(${total_population}, 0) ;; - } - measure: pct_black { - label: "Black/African American % of Population" - group_label: "Race" - type: number - value_format_name: percent_2 - sql: ${black_alone_or_in_combo}/NULLIF(${total_population}, 0) ;; - } - measure: pct_asian { - label: "Asian % of Population" - group_label: "Race" - type: number - value_format_name: percent_2 - sql: ${asian_alone_or_in_combo}/NULLIF(${total_population}, 0) ;; - } - measure: pct_amind { - label: "American Indian or Native Alaskan % of Population" - group_label: "Race" - type: number - value_format_name: percent_2 - sql: ${amind_alone_or_in_combo}/NULLIF(${total_population}, 0) ;; - } - measure: pct_nathaw { - label: "Native Hawaiian or Other Pacific Islander % of Population" - group_label: "Race" - type: number - value_format_name: percent_2 - sql: ${nat_haw_alone_or_in_combo}/NULLIF(${total_population}, 0) ;; - } - measure: pct_white_nh { - label: "White, Non-Hispanic % of Population" - group_label: "Race" - type: number - value_format_name: percent_2 - sql: ${white_non_hisp}/NULLIF(${total_population}, 0) ;; - } - - measure: hispanic_or_latino { - label: "Hispanic or Latino Population (Any Race)" - type: sum - sql: ${TABLE}.hispanic_or_latino ;; - group_label: "Hispanic/Latino" - } - measure: pct_hispanic_or_latino { - label: "Hispanic or Latino % of Population (Any Race)" - type: number - sql: ${hispanic_or_latino}/NULLIF(${total_population}, 0) ;; - group_label: "Hispanic/Latino" - value_format_name: percent_2 - } - measure: pct_non_hispanic_or_latino { - label: "Non-Hispanic, Non-Latino % of Population (Any Race)" - type: number - sql: 1-(${hispanic_or_latino}/NULLIF(${total_population}, 0)) ;; - group_label: "Hispanic/Latino" - value_format_name: percent_2 - } - measure: pct_white_nh2 { - label: "White, Non-Hispanic % of Population" - group_label: "Hispanic/Latino" - type: number - value_format_name: percent_2 - sql: ${white_non_hisp}/NULLIF(${total_population}, 0) ;; - } - - measure: under_18 { - label: "Population 17 years and younger" - type: sum - sql: ${TABLE}.under_18 ;; - group_label: "Age" - } - measure: eighteen_to_64 { - label: "Population 18 to 64 years" - type: sum - sql: ${TABLE}.eighteen_to_64 ;; - group_label: "Age" - } - measure: sixty_five_and_over { - label: "Population 65 years and older" - type: sum - sql: ${TABLE}.sixty_five_and_over ;; - group_label: "Age" - } - measure: pct_under_18 { - label: "% of Population 17 years and younger" - type: number - sql: ${under_18}/NULLIF(${total_population}, 0) ;; - group_label: "Age" - value_format_name: percent_2 - } - measure: pct_18_64 { - label: "% of Population 18 and 64 years" - type: number - sql: ${eighteen_to_64}/NULLIF(${total_population}, 0) ;; - group_label: "Age" - value_format_name: percent_2 - } - measure: pct_65_over { - label: "% of Population 65 and older" - type: number - sql: ${sixty_five_and_over}/NULLIF(${total_population}, 0) ;; - group_label: "Age" - value_format_name: percent_2 - } - - -} diff --git a/bq.explore.lkml b/bq.explore.lkml deleted file mode 100644 index 58ef50a..0000000 --- a/bq.explore.lkml +++ /dev/null @@ -1,26 +0,0 @@ -include: "bq.*.view.lkml" - - -explore: fast_facts { - from: bq_logrecno_bg_map - - join: block_group_facts { - from: bq_block_group_facts - view_label: "Fast Facts" - sql_on: ${fast_facts.block_group} = ${block_group_facts.logrecno_bg_map_block_group};; - relationship: one_to_one - } - - join: tract_zcta_map { - from: bq_tract_zcta_map - sql_on: ${fast_facts.geoid11} = ${tract_zcta_map.geoid11};; - relationship: many_to_one - } - - join: zcta_distances { - from: bq_zcta_distances - sql_on: ${tract_zcta_map.ZCTA5} = ${zcta_distances.zip2} ;; - relationship: one_to_one - required_joins: [tract_zcta_map] - } -} diff --git a/bq.geo_map.view.lkml b/bq.geo_map.view.lkml deleted file mode 100644 index ffe5773..0000000 --- a/bq.geo_map.view.lkml +++ /dev/null @@ -1,202 +0,0 @@ -view: bq_logrecno_bg_map { - label: "Geography" - derived_table: { - sql: - SELECT - UPPER(stusab) as stusab, - logrecno, - CONCAT(UPPER(stusab), CAST(logrecno AS STRING)) as row_id, - sumlevel, - state as state_fips_code, - county as county_fips_code, - tract, - blkgrp, - SUBSTR(geo.geoid, 8, 11) as geoid11, - geo.geoid, - CASE - WHEN sumlevel = '140' - THEN REGEXP_EXTRACT(name, r'^[^,]*, [^,]*, ([^,]*)') - WHEN sumlevel = '150' - THEN REGEXP_EXTRACT(name, r'^[^,]*, [^,]*, [^,]*, ([^,]*)') - END as state_name, - CASE - WHEN sumlevel = '140' - THEN REGEXP_EXTRACT(name, r'^[^,]*, ([^,]*), [^,]*') - WHEN sumlevel = '150' - THEN REGEXP_EXTRACT(name, r'^[^,]*, [^,]*, ([^,]*), [^,]*') - END as county_name, - CASE - WHEN sumlevel = '140' - THEN REGEXP_EXTRACT(name, r'^([^,]*), [^,]*, [^,]*') - WHEN sumlevel = '150' - THEN REGEXP_EXTRACT(name, r'^[^,]*, ([^,]*), [^,]*, [^,]*') - END as tract_name, - CASE - WHEN sumlevel = '150' - THEN REGEXP_EXTRACT(name, r'^([^,]*), [^,]*, [^,]*, [^,]*') - END as block_group_name, - CASE WHEN geo.SUMLEVEL = '150' THEN bg.INTPTLAT END as latitude, - CASE WHEN geo.SUMLEVEL = '150' THEN bg.INTPTLON END as longitude, - SUM(COALESCE(bg.ALAND, tr.ALAND) * 0.000000386102159) AS square_miles_land, - SUM(COALESCE(bg.AWATER, tr.AWATER) * .000000386102159) AS square_miles_water - FROM - `looker-datablocks.acs_fast_facts.geo_2015` as geo - LEFT JOIN `looker-datablocks.acs_fast_facts.block_group_attribs` as bg on (SUBSTR(geo.GEOID, 8, 12) = bg.geoid AND geo.SUMLEVEL = '150') - LEFT JOIN `looker-datablocks.acs_fast_facts.block_group_attribs` as tr on (SUBSTR(geo.GEOID, 8, 11) = SUBSTR(tr.geoid, 1, 11) AND geo.SUMLEVEL = '140') - WHERE - sumlevel in ('140', '150') - GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ;; - persist_for: "10000 hours" - } - dimension: row_id {sql: ${TABLE}.row_id;; - primary_key:yes - hidden: yes - } - dimension: geoid11 {hidden:yes} - dimension: logrecno {hidden:yes} - dimension: blkgrp {hidden:yes} - dimension: sumlevel {hidden:yes sql: ${TABLE}.sumlevel;;} - - # State - - dimension: stusab { - label: "State Abbreviation" - group_label: "State" - link: { - url: "https://maps.google.com?q={{value}}" - label: "Google Maps" - } - suggest_persist_for: "120 hours" - } - - dimension: state_name { - group_label: "State" - map_layer_name: us_states - sql: ${TABLE}.state_name;; - link: { - url: "https://maps.google.com?q={{value}}" - label: "Google Maps" - } - suggest_persist_for: "120 hours" - drill_fields: [county, tract] - } - - dimension: state { - group_label: "State" - label: "State FIPS Code" - sql: ${TABLE}.state_fips_code;; - suggest_persist_for: "120 hours" - } - -# measure: count_state { -# type: count_distinct -# sql: ${state_name} ;; -# drill_fields: [state_name, data.default_drills*, count_county, count_tract, count_block] -# } - - # County - - dimension: county { - group_label: "County" - label: "County FIPS Code" - sql: CONCAT(${state}, ${TABLE}.county_fips_code);; - map_layer_name: us_counties_fips - drill_fields: [tract, block_group] - suggest_persist_for: "120 hours" - } - - dimension: county_name { - group_label: "County" - sql: CONCAT(${TABLE}.county_name, ', ', ${state_name});; - link: { - url: "https://maps.google.com?q={{value}}" - label: "Google Maps" - } - suggest_persist_for: "120 hours" - } - -# measure: count_county { -# type: count_distinct -# sql: ${county_name} ;; -# drill_fields: [county_name, data.default_drills*, count_tract, count_block,] -# } - - # Tract - - dimension: tract { - label: "Tract Geo Code" - group_label: "Tract" - sql: ${TABLE}.geoid11 ;; - map_layer_name: tract - suggest_persist_for: "120 hours" - } - - dimension: tract_name { - sql: CONCAT(${TABLE}.tract_name, ', ', ${county_name});; - group_label: "Tract" - link: { - url: "https://google.com?q={{value}}" - label: "Google" - } - suggest_persist_for: "120 hours" - } - -# measure: count_tract { -# type: count_distinct -# sql: ${tract_name} ;; -# drill_fields: [tract_name, data.default_drills*, count_block] -# } - - # Block Group - - dimension: block_group { - sql: SUBSTR(${TABLE}.geoid, 8, 12);; - group_label: "Block Group" - label: "Block Group Geo Code" - map_layer_name: block_group - link: { - url: "https://google.com?q={{value}}" - label: "Google" - } - suggest_persist_for: "120 hours" - } - - dimension: block_group_name { - sql: CONCAT(${TABLE}.block_group_name, ', ', ${tract_name}) ;; - group_label: "Block Group" - suggest_persist_for: "120 hours" - } - - dimension: block_group_centroid { - type: location - sql_latitude: ${TABLE}.latitude ;; - sql_longitude: ${TABLE}.longitude ;; - group_label: "Block Group" - suggest_persist_for: "120 hours" - } - - measure: sq_miles_land { - sql: ${TABLE}.square_miles_land ;; - label: "Square Miles of Land" - type: sum - value_format_name: decimal_2 - } - - measure: sq_miles_water { - sql: ${TABLE}.square_miles_water ;; - label: "Square Miles of Water" - type: sum - value_format_name: decimal_2 - } - -# measure: count_block { -# type: count_distinct -# sql: ${block_group} ;; -# drill_fields: [tract_name, data.default_drills*] -# } -# -# -# set: geo_drills { -# fields: [count_state, count_county, count_tract, block_group] -# } -} diff --git a/bq.tract_zcta_map.view.lkml b/bq.tract_zcta_map.view.lkml deleted file mode 100644 index 72b367e..0000000 --- a/bq.tract_zcta_map.view.lkml +++ /dev/null @@ -1,39 +0,0 @@ - -view: bq_tract_zcta_map { - label: "Geography" - derived_table: { - sql: - SELECT geoid, ZCTA5 FROM - (select *, ROW_NUMBER() OVER (PARTITION BY GEOID ORDER BY ZPOPPCT DESC) row_num - from `looker-datablocks.acs_fast_facts.zcta_to_tract_w_state`) - WHERE row_num = 1;; - persist_for: "10000 hours" - } - view_label: "Geography" - dimension: geoid11 {sql: ${TABLE}.geoid;; hidden:yes} - dimension: ZCTA5 { - sql: LPAD(CAST(${TABLE}.ZCTA5 as STRING), 5, '0');; - type: zipcode - label: "ZIP (ZCTA)" - } -} - -map_layer: block_group { - format: "vector_tile_region" - url: "https://a.tiles.mapbox.com/v4/dwmintz.4mqiv49l/{z}/{x}/{y}.mvt?access_token=pk.eyJ1IjoiZHdtaW50eiIsImEiOiJjajFoemQxejEwMHVtMzJwamw4OXprZWg0In0.qM9sl1WAxbEUMVukVGMazQ" - feature_key: "us_block_groups_simple-c0qtbp" - extents_json_url: "https://cdn.rawgit.com/dwmintz/census_extents2/59fa2cd8/bg_extents.json" - min_zoom_level: 9 - max_zoom_level: 14 - property_key: "GEOID" -} - -map_layer: tract { - format: "vector_tile_region" - url: "https://a.tiles.mapbox.com/v4/dwmintz.3zfb3asw/{z}/{x}/{y}.mvt?access_token=pk.eyJ1IjoiZHdtaW50eiIsImEiOiJjajFoemQxejEwMHVtMzJwamw4OXprZWg0In0.qM9sl1WAxbEUMVukVGMazQ" - feature_key: "us_tracts-6w08eq" - extents_json_url: "https://cdn.rawgit.com/dwmintz/census_extents2/396e32db/tract_extents.json" - min_zoom_level: 6 - max_zoom_level: 12 - property_key: "GEOID" -} diff --git a/bq.zcta_distances.view.lkml b/bq.zcta_distances.view.lkml deleted file mode 100644 index 7296536..0000000 --- a/bq.zcta_distances.view.lkml +++ /dev/null @@ -1,45 +0,0 @@ -view: bq_zcta_distances { - - derived_table: { - sql: SELECT * - FROM - `looker-datablocks.acs_fast_facts.zcta_distances_*` - WHERE - zip1 = {% parameter zcta_distances.zip1 %} - AND _TABLE_SUFFIX = SUBSTR( {% parameter zcta_distances.zip1 %}, 0, 1) - UNION ALL - SELECT - {% parameter zcta_distances.zip1 %} as zip1, - {% parameter zcta_distances.zip1 %} as zip2, - 0 - ;; - - } - - dimension: mi_to_zcta5 { - label: "Miles from selected ZIP" - view_label: "Geography" - group_label: "ZIP Radii" - type: number - sql: ${TABLE}.mi_to_zcta5 ;; - value_format_name: decimal_2 - } - - dimension: zip1 { - label: "Selected ZIP Code" - view_label: "Geography" - group_label: "ZIP Radii" - type: zipcode - sql: ${TABLE}.zip1 ;; - suggestable: no - } - - dimension: zip2 { - label: "Nearby ZIP" - view_label: "Geography" - group_label: "ZIP Radii" - type: zipcode - sql: ${TABLE}.zip2 ;; - hidden: yes - } - } diff --git a/bq_acs_2015.model.lkml b/bq_acs_2015.model.lkml deleted file mode 100644 index 2464a6b..0000000 --- a/bq_acs_2015.model.lkml +++ /dev/null @@ -1,4 +0,0 @@ -connection: "bq-looker-datablocks" - -# include all the BQ view files -include: "bq.explore" diff --git a/rs.block_group_facts.view.lkml b/rs.block_group_facts.view.lkml index 78e5724..8ce1427 100644 --- a/rs.block_group_facts.view.lkml +++ b/rs.block_group_facts.view.lkml @@ -1,5 +1,6 @@ view: rs_block_group_facts { - sql_table_name: datablocks_spectrum.fast_facts ;; + label: "Fast Facts" + sql_table_name: xplenty.fast_facts ;; dimension: logrecno_bg_map_block_group { hidden: yes @@ -162,7 +163,7 @@ view: rs_block_group_facts { type: number sql: ${hispanic_or_latino}/NULLIF(${total_population}, 0) ;; group_label: "Hispanic/Latino" - value_format_name: percent_2 + value_format_name: percent_4 } measure: pct_non_hispanic_or_latino { label: "Non-Hispanic, Non-Latino % of Population (Any Race)" diff --git a/rs.geo_map.view.lkml b/rs.geo_map.view.lkml index 5b450d6..f263dc1 100644 --- a/rs.geo_map.view.lkml +++ b/rs.geo_map.view.lkml @@ -5,50 +5,56 @@ view: rs_logrecno_bg_map { SELECT UPPER(stusab) as stusab, logrecno, - CONCAT(UPPER(stusab), CAST(logrecno AS STRING)) as row_id, + (UPPER(stusab) || logrecno::varchar) as row_id, + -- edited LOOKML - originally was 'concat' sumlevel, state as state_fips_code, county as county_fips_code, tract, blkgrp, - SUBSTR(geo.geoid, 8, 11) as geoid11, + CASE WHEN SUBSTRING(SUBSTRING(geo.geoid, 8, 11),1,1) = 0 THEN SUBSTRING(geo.geoid, 9, 10) ELSE SUBSTRING(geo.geoid, 8, 11) END AS geoid11, --SUBSTRING(geo.geoid, 8, 11) as geoid11, geo.geoid, - CASE + trim(' ' from CASE WHEN sumlevel = '140' - THEN REGEXP_EXTRACT(name, r'^[^,]*, [^,]*, ([^,]*)') + THEN SPLIT_PART(name, ',', 3) WHEN sumlevel = '150' - THEN REGEXP_EXTRACT(name, r'^[^,]*, [^,]*, [^,]*, ([^,]*)') - END as state_name, - CASE + THEN SPLIT_PART(name, ',', 4) + END) as state_name, + trim(' ' from CASE WHEN sumlevel = '140' - THEN REGEXP_EXTRACT(name, r'^[^,]*, ([^,]*), [^,]*') + THEN SPLIT_PART(name, ',', 2) WHEN sumlevel = '150' - THEN REGEXP_EXTRACT(name, r'^[^,]*, [^,]*, ([^,]*), [^,]*') - END as county_name, - CASE + THEN SPLIT_PART(name, ',', 3) + END) as county_name, + name, + trim(' ' from CASE WHEN sumlevel = '140' - THEN REGEXP_EXTRACT(name, r'^([^,]*), [^,]*, [^,]*') + THEN SPLIT_PART(name, ',', 1) WHEN sumlevel = '150' - THEN REGEXP_EXTRACT(name, r'^[^,]*, ([^,]*), [^,]*, [^,]*') - END as tract_name, - CASE + THEN SPLIT_PART(name, ',', 2) + END) as tract_name, + trim(' ' from CASE WHEN sumlevel = '150' - THEN REGEXP_EXTRACT(name, r'^([^,]*), [^,]*, [^,]*, [^,]*') - END as block_group_name, + THEN SPLIT_PART(name, ',', 1) + END) as block_group_name, CASE WHEN geo.SUMLEVEL = '150' THEN bg.INTPTLAT END as latitude, CASE WHEN geo.SUMLEVEL = '150' THEN bg.INTPTLON END as longitude, SUM(COALESCE(bg.ALAND, tr.ALAND) * 0.000000386102159) AS square_miles_land, SUM(COALESCE(bg.AWATER, tr.AWATER) * .000000386102159) AS square_miles_water FROM - datablocks_spectrum.geo_2015 as geo - LEFT JOIN datablocks_spectrum.block_group_attribs as bg on (SUBSTR(geo.GEOID, 8, 12) = bg.geoid AND geo.SUMLEVEL = '150') - LEFT JOIN datablocks_spectrum.block_group_attribs as tr on (SUBSTR(geo.GEOID, 8, 11) = SUBSTR(tr.geoid, 1, 11) AND geo.SUMLEVEL = '140') + xplenty.geo2015 as geo + LEFT JOIN xplenty.block_group_attribs as bg on (SUBSTRING(geo.GEOID, 8, 12) = bg.geoid AND geo.SUMLEVEL = '150') + LEFT JOIN xplenty.block_group_attribs as tr on (SUBSTRING(geo.GEOID, 8, 11) = SUBSTRING(tr.geoid, 1, 11) AND geo.SUMLEVEL = '140') WHERE - sumlevel in ('140', '150') - GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ;; + sumlevel in ('140','150') + GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ;; persist_for: "10000 hours" distribution_style: all } + + + + dimension: row_id {sql: ${TABLE}.row_id;; primary_key:yes hidden: yes @@ -100,7 +106,10 @@ view: rs_logrecno_bg_map { dimension: county { group_label: "County" label: "County FIPS Code" - sql: CONCAT(${state}, ${TABLE}.county_fips_code);; + sql: (${state} || ${TABLE}.county_fips_code) + -- edited LOOKML - originally was 'concat' + ;; + map_layer_name: us_counties_fips drill_fields: [tract, block_group] suggest_persist_for: "120 hours" @@ -108,7 +117,9 @@ view: rs_logrecno_bg_map { dimension: county_name { group_label: "County" - sql: CONCAT(${TABLE}.county_name, ', ', ${state_name});; + sql: (${TABLE}.county_name || ', ' || ${state_name}) + -- edited LOOKML - originally was 'concat' + ;; link: { url: "https://maps.google.com?q={{value}}" label: "Google Maps" @@ -133,7 +144,9 @@ view: rs_logrecno_bg_map { } dimension: tract_name { - sql: CONCAT(${TABLE}.tract_name, ', ', ${county_name});; + sql: ${TABLE}.tract_name || ', ' || ${county_name} + -- edited LOOKML - originally was 'concat' + ;; group_label: "Tract" link: { url: "https://google.com?q={{value}}" @@ -151,7 +164,7 @@ view: rs_logrecno_bg_map { # Block Group dimension: block_group { - sql: SUBSTR(${TABLE}.geoid, 8, 12);; + sql: SUBSTRING(${TABLE}.geoid, 8, 12);; group_label: "Block Group" label: "Block Group Geo Code" map_layer_name: block_group @@ -163,7 +176,9 @@ view: rs_logrecno_bg_map { } dimension: block_group_name { - sql: CONCAT(${TABLE}.block_group_name, ', ', ${tract_name}) ;; + sql: (${TABLE}.block_group_name || ', ' || ${tract_name}) + -- edited LOOKML - originally was 'concat' +;; group_label: "Block Group" suggest_persist_for: "120 hours" } diff --git a/rs.explore.lkml b/rs.model.lkml similarity index 88% rename from rs.explore.lkml rename to rs.model.lkml index dd92812..a669f97 100644 --- a/rs.explore.lkml +++ b/rs.model.lkml @@ -1,4 +1,6 @@ include: "rs.*.view.lkml" +label: "rs_demo_data" +connection: "redshift" explore: fast_facts { from: rs_logrecno_bg_map @@ -23,3 +25,6 @@ explore: fast_facts { required_joins: [tract_zcta_map] } } + + +explore: rs_logrecno_bg_map { } diff --git a/rs.tract_zcta_map.view.lkml b/rs.tract_zcta_map.view.lkml index 5a3add8..4e0ef28 100644 --- a/rs.tract_zcta_map.view.lkml +++ b/rs.tract_zcta_map.view.lkml @@ -6,7 +6,7 @@ view: rs_tract_zcta_map { sql: SELECT geoid, ZCTA5 FROM (select *, ROW_NUMBER() OVER (PARTITION BY GEOID ORDER BY ZPOPPCT DESC) row_num - from datablocks_spectrum.zcta_to_tract_w_state) + from xplenty.zcta_to_tract_w_state) WHERE row_num = 1;; persist_for: "10000 hours" distribution_style: all @@ -14,7 +14,7 @@ view: rs_tract_zcta_map { view_label: "Geography" dimension: geoid11 {sql: ${TABLE}.geoid;; hidden:yes} dimension: ZCTA5 { - sql: LPAD(CAST(${TABLE}.ZCTA5 as STRING), 5, '0');; + sql: LPAD(CAST(${TABLE}.ZCTA5 as varchar), 5, '0');; type: zipcode label: "ZIP (ZCTA)" } diff --git a/rs.zcta_distances.view.lkml b/rs.zcta_distances.view.lkml index ec59666..c345da7 100644 --- a/rs.zcta_distances.view.lkml +++ b/rs.zcta_distances.view.lkml @@ -3,7 +3,7 @@ view: rs_zcta_distances { derived_table: { sql: SELECT * FROM - datablocks_spectrum.zcta_distances + xplenty.zcta_distances WHERE zip1 = {% parameter zcta_distances.zip1 %} UNION ALL @@ -12,32 +12,32 @@ view: rs_zcta_distances { {% parameter zcta_distances.zip1 %} as zip2, 0 ;; - } + } - dimension: mi_to_zcta5 { - label: "Miles from selected ZIP" - view_label: "Geography" - group_label: "ZIP Radii" - type: number - sql: ${TABLE}.mi_to_zcta5 ;; - value_format_name: decimal_2 - } + dimension: mi_to_zcta5 { + label: "Miles from selected ZIP" + view_label: "Geography" + group_label: "ZIP Radii" + type: number + sql: ${TABLE}.mi_to_zcta5 ;; + value_format_name: decimal_2 + } - dimension: zip1 { - label: "Selected ZIP Code" - view_label: "Geography" - group_label: "ZIP Radii" - type: zipcode - sql: ${TABLE}.zip1 ;; - suggestable: no - } + dimension: zip1 { + label: "Selected ZIP Code" + view_label: "Geography" + group_label: "ZIP Radii" + type: zipcode + sql: ${TABLE}.zip1 ;; + suggestable: no + } - dimension: zip2 { - label: "Nearby ZIP" - view_label: "Geography" - group_label: "ZIP Radii" - type: zipcode - sql: ${TABLE}.zip2 ;; - hidden: yes - } + dimension: zip2 { + label: "Nearby ZIP" + view_label: "Geography" + group_label: "ZIP Radii" + type: zipcode + sql: ${TABLE}.zip2 ;; + hidden: yes } +} diff --git a/rs_acs_2015.model.lkml b/rs_acs_2015.model.lkml index d153fcc..d5a16b5 100644 --- a/rs_acs_2015.model.lkml +++ b/rs_acs_2015.model.lkml @@ -1,3 +1,3 @@ -connection: "datablocks_spectrum" +connection: "redshift" -include: "rs.explore" +#include: "rs.explore"