Finding the First and Last Rows for a Student

Modified on Thu, Nov 30, 2023 at 12:50 PM

CAVEAT:  Before reading this section please read the Column Processing Model article:
READ FIRST: The Column Processing Model for Expression Processing


"Finding the First and Last Rows for a Student" is a basic and very powerful technique that enable a great number of additional techniques.


This technique relies on the following:

  • Use of the "prevRow" and "nextRow" tools to look at data in the previous and next rows of the output matrix (i.e. "report").
  • Making sure the report is sorted correctly before trying this technique: this has to happen after the 'sort' or it must rely on a 'natural sort' having occurred by how data was looked up and added to the report 


What are the First Row and Last Row for a Student?

In a group of rows that are all for one student, the "first row for the student" is just that:  the first row in the set of rows for that one student.  The "last row for the student", similarly, is the final row in the cluster of rows for one student.    For the corresponding Expressions to do their job, the report must be sorted so that each student's rows are clustered into a single group.    This can happen automatically, when rows are joined to the student table, or specifically, by doing an explicit sort.


Sample definitions (and abbreviations) for First and Last Row for Student columns:


These are columns that return Boolean values:  true or false.


Finding the First Row for a Student

This relies on the rows of the report being sorted in such a way that all rows for a student are clustered together.   


The first row for a student is the row where the "Student ID" field in the current row contains a different value from the Student ID field in the previous row:     ${ row.studentID != prevRow.studentID }



What you name your column is irrelevant.  What is important is the Expression it contains.  Again:   ${ row.studentID != prevRow.studentID} 


This column will be true when the current row contains a studentID that differs from the previous row.  It will be false for all other rows.


If you require a sort to order your rows, you must check the "Evaluate this expression after sorting rows" checkbox.


Finding the Last Row for a Student

This also relies on the rows of the report being sorted in such a way that all rows for a student are clustered together.   


The last row for a student is the row where the "Student ID" field in the current row contains a different value from the Student ID field in the next row:     ${ row.studentID != nextRow.studentID }



What you name your column is irrelevant.  What is important is the Expression it contains.  Again:   ${ row.studentID != nextRow.studentID} 


This column will be true when the current row contains a studentID that differs from the next or following row.  It will be false for all other rows.


If you require a sort to order your rows, you must check the "Evaluate this expression after sorting rows" checkbox.


Consequences of Checking the "Evaluate this expression after sorting rows" Checkbox

If this checkbox is checked for either the first row for student or last row for student columns, it must be checked in every column that will then use those columns for further processing.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article