We are using US Census
data to create a visual that uses the Percentage of Previous analytic function.
To use the Percentage of Previous analytic function with US Census
data, follow the general steps in the Example.
US Census
dataset, download the census-pop.csv.zip file, uncompress it, Importing Data into Arcadia, and Creating Datasets.The input set up for the Percentage of Previous visual follows:
state
sum(population)
, for nowyear
sum(population)
, sum(year)
Filters shelf: exclude the following years of the census: 1790
and 1800
.
There is insufficient data for these years, and it skews the results.
On the Y shelf, click the icon to the right of the variable.
In the dropdown, hover over Analytic Functions.
In the Analytic Function: Current Row as Percent of Previous Row modal window,
Under Select the sort order, click the (add/plus) icon, select year, and then set it to ascending sort order.
Note that you can add additional sort parameters, by clicking the (add/plus) icon.
Click Refresh Visual.
Note the expression used for calculating the percentage of previous:
sum([population]) / lag(sum([population]), 1) over (partition by [state] order by [year]) as 'previous percent(population)'
Follow these general steps to create a running total visual:
When creating or editing a visual, determine for which field variable you must apply an analytic function.
The shelves that support analytic functions depend on the visual type, and are typically available for X and Y axes, Measures, Dimensions, Colors, and Tooltips.
Click the icon to the right of the variable.
In the dropdown, click Analytic Functions.
From the Analytic Functions menu, select Percentage of previous.
The Analytical Function: Current Row as Percent of Previous Row modal window appears.
In the Analytical Function: Current Row as Percent of Previous Row modal window, in Select aggregate for this measure, choose one of:
[Optional] Under Select the sort order, specify the sort order. If you don't specify it, the current column's aggregate is the sort order.