Building Visuals with Arcadia Instant: Economic Power

Published on November 4, 2015

Let’s say you want to make an app that explores total GDP over time. On the “World Population Distribution in 2010” viz editing tab, you’ll see a field called “gdp_per_capita” (under measures in the data source sidebar).But we don’t actually have a GDP field. In this section, you’ll learn how to create a new field so that it will show up wherever the dataset may be used. We’ll also cover creating new visuals via cloning and creating a new app with several filter interactions between vizes.

Calculating a New Field: GDP

The best place to define a new calculation is in the dataset. This means you only have to define a calculation once, and it will appear in the data source list whenever you or anyone else uses that dataset for any visuals. There are two ways to get to the datasource / dataset list.

  • Approach 1: Click “Data” at the top of the screen, then click “Samples” in the sidebar if it isn’t already selected, then under “Datasets” click “World Life Expectancy.”

      image20  

  • Approach 2: From your “Edit World Population Distribution in 2010” tab, click the “edit dataset” icon in the dataset sidebar.
      image10  
  1. On the dataset page, click “Attributes” on the sidebar. This brings up all the dimension and measure fields from the “World Life Expectancy” dataset.
  2. Click “Edit Attributes.” This will let you make changes to the fields in the dataset that apply to all visuals and apps that use this dataset.
      image14  

Now you need to create a field called “GDP.”

  1. Clone population. (Click the small double sheet icon next to the population field.)
  2. Click your new measure “Copy of population” to rename it and apply a calculation.
  3. Change the “Display Name” to “GDP (billions)”
  4. In the expression text box, enter ( [population]*[gdp_per_capita] ) / 1000000000.
  5. Click “Apply” and then the blue “Save” button.
      image16  

While you’re on the “Attributes” screen, you can edit the “Display Names” of any of the other fields that you may want to rename. For example, change “year” to “Year.” Again, make sure you click the blue “Save” button.

Now that you have the GDP calculation, let’s put it into action.

Aside: Expressions Syntax and Underlying Databases Type

You have already entered a couple of expressions in the above tutorials, and you may wonder what kind of functions can be used here. The answer is that the syntax used here varies by the type of database that stores all your information.

The “Samples” connection that comes packaged with Arcadia Instant is a SQLite database, so you may use most SQLite functions that would work in a “Select” statement (see http://www.sqlite.org/lang.html). Aggregate functions and core functions listed on that page are the most useful. If you import your own data in a csv into Arcadia, it will be in the Samples SQLite database, unless you create a connection to another database.

As we mentioned earlier, Arcadia Instant currently supports three database types common to Hadoop: SQLite, Hive, and Impala. Arcadia Enterprise adds support for MySQL/MariaDB, PostgreSQL, and Amazon Redshift. So if you connect to one of these databases, you’ll need to use that database-specific syntax in the expressions.

Most of the following functions are available (particularly true for Impala connections): http://www.cloudera.com/content/cloudera/en/documentation/cloudera-impala/latest/topics/impala_functions.html

Note: Arcadia Enterprise has a back-end engine that provides a more unified syntax.

Cloning and Revising a Viz

Remember that viz we were revising earlier, “World Population Distribution in 2010?” You’re now going to clone it and change it to “Economic Power in 2010.”

image12

  1. On the World Population Distribution screen click “Clone.” It will open a in a new window. You’ll notice that the title now says “Clone of World Population Distribution in 2010.” Click the “Edit” button right next to this in order to rename it “Economic Power in <<[Year]:2010>>”.
  2. Drag the “GDP (billions)” pill from the data source sidebar onto the measures shelf and remove the “Population” pill.
  3. As before with Population, click the “GDP (billions)” pill. In the dropdown menu, choose “Aggregates->Remove Aggregate,” and in “Display Format” enter ,.2f.
  4. Click the orange “Save” button and then click “Refresh Visual.”
      image27  

The result should look like the following:

image22

I like the somewhat random appearance of the unsorted packed bubble chart, but you can also make it spiral in (or out) by clicking on the “GDP (billions)” pill and selecting “Order->Descending or Ascending” if you want it to appear a little neater.

Click here to continue using the “Economic Power” visualization to create an interactive application