Step 8 - Grade Level Sorting
Tutorial 2 for Pro Version: Using Report Bands
Step 8 - Grade Level Sorting (*If Necessary)
The grade levels in your chart may be sorted incorrectly.
For example, you may notice that Grades "10, "11", or "12" are not in the right order. Or, you may notice that Grades "K", "TK", "PreK", etc. are showing last.
This is happening because the Grade Level field is a "String" (aka "text") field, and the chart is sorting the grade levels alphabetically.
There are two scenarios, which will call for different solutions:
Scenarios
Your data includes only numeric grade levels (i.e. Grades 1-12, but NOT Grades K, TK, etc.)
Your data includes non-numeric grade levels (i.e. Grades K, TK, etc.)
Scenario 1 - Numeric Grade Levels Only
If your dataset includes only numeric grade levels, you can simply tell Jaspersoft to treat your Grade Level
field as if it were an Integer, and it will sort your grade levels correctly.
Navigate to your Outline tab
Select the
Current Grade Level
field under the "Fields" section in your outline.Go to the Properties tab
Change the Class to
java.lang.Integer
Preview your report. Your grade levels should now be sorting correctly.
WARNING: If, at any point, the dataset includes a grade level that is not numeric, the report will throw an error and will not run.
Only use this method if you are absolutely sure the dataset for this report will never include non-numeric grade levels.
Scenario 2 - Data Contains Non-numeric Grade Levels
If your dataset includes non-numeric grade levels, you'll need to create a variable that transforms your grade levels into pure numeric values.
Create "Grade Level Numeric" Variable
Navigate to your Outline tab
Right-click on the Variables section in your outline
Select Create Variable
Select the newly created Variable_1 variable in the outline
Rename the variable to: "Grade Level Numeric"
Set the Value Class Name to
java.lang.Integer
Click the pencil icon to the right of the expression field to bring up the expression editor.
Translate Grade Levels to Numeric Values
TIP: Know your data! To use the BI Tool effectively, you need to know your data. Look at the data in your custom report. Grade Levels are unique to your instance of Illuminate. Do you have "Pre-K"? "TK"? etc. You may need to adjust the expression below to account for the grade levels you have in your Illuminate site.
In the expression editor,
Write the following Expression:
You may need to customize the expression to account for the unique grade levels that you have in your Illuminate site.
What is this expression doing?
If the current grade level is "TK", then output -1
. If the current grade level is "K", then output 0
.
Otherwise, output the integer value of the current grade level.
Refer to Basics of Writing Expressions in JSS for detailed documentation on writing expressions in JSS.
Create a Sort Field
Now, we need to sort our data using this "Grade Level Numeric" variable that we just created.
Navigate to the Outline tab
Right-click on Sort Fields
Select Create Sort Field
Select Grade Level Numeric
Click Finish
Remove Sorting (a.k.a "Order") Default from Chart
Finally, we need to remove the sorting from the chart. By default, HTML5 Charts will re-sort your data, based on your Category Level. In this case however, we are pre-sorting the data using the "Grade Level Numeric" variable, so we need to tell the chart not to re-sort our data.
Double-click on the chart
Click Chart Data > Configuration
Double-click on the "Grade Level" category level (or click Modify)
Change the Order field from "Ascending" to "None"
Click Finish
Preview your report. The grade levels should now be sorting correctly.
Did you know Illuminate can build your BI Tool for you? Click here to learn about Illuminate's Report Building Service.
Last updated
Was this helpful?