Skip to main content

Working with a focus row

"Describe Row in Context" projects generate a separate narrative for each row in your data table. In this respect, they are similar to "Describe Each Row" projects, which we covered in the first tutorial.

The important difference is that "Describe Row in Context" projects allow you to construct a narrative that refers to data from outside the focus row (i.e. the row for which the narrative is being generated). This requires a more complex data access mechanism.

This first part of the tutorial, however, covers working with a focus row.

  1. Go to the Project Portal and click New Project > Describe Row in Context.

    Working with a Focus Row 01 NEW.png
  2. Name your project to your liking.

  3. Import the CSV data file (AustralianStates.csv).

    Important

    This tutorial uses the same dataset used for the "Describe Each Row" tutorial. If you don’t have the CSV data file saved to your local drive, you can download it again by clicking HERE.

  4. Click Compose.

    Our narrative is going to have two paragraphs: one that describes the state, and another that describes the capital of that state.

  5. Create two subscripts, State and CapitalCity, then insert calls to these subscripts in the Main script:

    Working with a Focus Row 02 NEW.png
  6. Go to the State subscript and add the following text: A has a land mass of B square kilometers and a population in 2016 of C, which is D% up on 2010's figure of E.

    Working with a Focus Row 03 NEW.png

    The first task is to replace A with a variable that returns the name of the state/territory. This information is contained in our data table's first column, which in this project type is the row names column. We need the row name for the focus row, and this is retrieved using a special variable called FocusRowName.

  7. Select A, click Insert Variable, then select FocusRowName from the drop-down.

    Working with a Focus Row 04 NEW.png

    Note

    The FocusRowName variable is unique to this project type.

    Next, we need to replace B with a variable that will return the land mass value for the focus row.

  8. Select B, click Insert Variable, then select StateLandArea from the drop-down.

    Working with a Focus Row 05 NEW.png

    Important

    The drop-down includes two similarly named variables: StateLandArea and StateLandAreaColumn. Both variables correspond to our data table's StateLandArea column; however, they return different data.

    At this particular stage of the tutorial, we need only the StateLandArea value for the focus row; therefore, we use the StateLandArea variable. If we used the StateLandAreaColumn variable instead, we would get a punctuated list of every value in the column. We will make use of this option later in the tutorial.

  9. Replace C and E with the relevant variables.

    Working with a Focus Row 06 NEW.png

    Note

    Again, we must use StatePop2016 and StatePop2010, rather than StatePop2016Column and StatePop2010Column, because we want data values for the focus row only.

    Next, we'll replace D with a call to the percentageChange function:

  10. Select D and then click Insert Function > math > percentageChange. This opens the Function Builder with the percentageChange function already selected.

  11. Select StatePop2016 in the NEW VALUE field and StatePop2010 in the OLD VALUE field, then click Save.

    Working with a Focus Row 07. NEWpng
  12. Click Preview. Your output text for Row 1 should be:

    New South Wales has a land mass of 800,641 square kilometers and a population in 2016 of 7,618,200, which is 5.24% up on 2010's figure of 7,238,800.

    You can preview the narrative for other rows using the navigation buttons. These should be familiar from the tutorial for "Describe Each Row" projects.

So far the "Describe Row in Context" project may be difficult to distinguish from the "Describe Each Row" project. All we have done is build a simple script that uses variables and functions to retrieve or calculate data values particular to the focus row.

The next part of the tutorial will demonstrate how to create more sophisticated narratives by using data from outside the focus row.

Identifying properties of a focus row