Name Game: Step 1: Simple Measures

  • 14 January 2016
  • 1 reply
  • 43 views

Userlevel 6
Badge

Step 1: Adding Simple Measures


In LookML, a measure is a summary or aggregate computation. The model below is really simple. We’ve just added a couple of measures: name count and total population. Now we should be able to answer lots of pretty basic questions about names.


Note: The code added in each step could be added to the view in Step 0. For this series of articles, we will instead use Looker’s extend functionality to extend the prior step’s view and then add new dimensions and measures. This enables us to just focus on the new functionality added for the current step.


#
# Add some very basic computations to
# calculate the number of different names
# the total size of the population

- view: names_step_1 # make a new view, names_step_1
extends: names_step_0 # use all the fields in names_step_0
# and add or change the following fields
fields:

# number of Different Names
- measure: name_count
type: count_distinct
sql: ${name}
drill_fields: [name, total_population]

# sum the populations
- measure: total_population
type: sum
sql: ${number}


Explore!


All of the queries below can be created by Exploring From Here. Select dimensions and measures, add filters and bonk the ‘Run Button’.


Most Common Names


Notice that we have to go down to the 6th name to find a common female name.



[Explore From Here](http://looker.com/publicdata/looks/7?show=fields,data)

Most Common Female Names



[Explore From Here](http://looker.com/publicdata/looks/10?show=fields,data)

Most Common Female Names in Recent Years (In 2000 or Later)



[Explore From Here](https://looker.com/publicdata/looks/122?show=fields,data)

Population By State



[Explore From Here](http://looker.com/publicdata/looks/134?show=fields,vis,data)

Population By State for Mary



[Explore From Here](http://looker.com/publicdata/looks/135?show=fields,vis,data)

Population By State for Mary before 1920



[Explore From Here](http://looker.com/publicdata/looks/136?show=fields,vis,data)

Are there more names now, than in the past?


Yes, and you can see the baby boom too.



[Explore From Here](http://looker.com/publicdata/looks/132?show=fields,vis,data)

Are there more boy or girl names?


Girl names, by a wide margin.



[Explore From Here](http://looker.com/publicdata/looks/11?show=fields,vis,data)

Let’s Compare Lisa, Elijah, Emily, Lloyd and Frank over Time.



[Explore From Here](http://looker.com/publicdata/looks/120?show=fields,vis,data)

Simple Widget that Lets You Compare Names


Here is a simple widget that lets you compare names. CHANGE the Filters and see what you can learn about names.



Here’s a list of all of the steps:



Go to the next Name Game page, Step 2: Computed Dimensions


1 reply

There seems to be at least a couple of wrong link on this page: “Most Common Female Names in Recent Years (In 2000 or Later)”, “Are there more names now, than in the past?” and some of the “Population by State” including the Explore From Here link to Diseases data, e.g. https://looker.com/publicdata/cdc/explore/12?.


Kind regards

Nicolai


Edit: I think the same is the case for the step 2 and 3. Links to CDC and Hacker News (unless I’m doing something wrong 🙂 )

Reply