[00:00]
In this lesson, we will look at performing calculations on data keys with keychains. Keychains have their own expression language that is similar in syntax to Java. Key chain expressions are configured by using different operators or functions within "@"s. Let's take a look at a basic report I've already set up to see these in action. My report has a SQL Query data source that's pulling fruit order data, and I've set up a table to display that data. Right now my first column is displaying the fruit and the second column is displaying the order quantity. As a quick example, I'll use the third column to display the order quantity, but multiplied by 10. I can drag the quantity key into the third column and then use keychain expressions within the edit text window. I'll add the multiplication operator, and the number 10, and as long as these are within the "@"s, these operations will be applied to the key and the result will be displayed. I'll clear out the third column and replace it with the price per piece. Then I'll use another expression in the fourth column that multiplies the order quantity by the price per piece.
[01:07]
I'll drag each key into the column, remove the extra at signs, and then put a multiplication operator between the two keys. If I want to add text to the column that doesn't get evaluated in a keychain expression, I can add it outside of the "@"s. For example, I'll place a "$" before the first "@" so that the values are shown as a dollar amount. Then I can also quickly change the number format by going to the properties and I'll change it so that it always shows two decimal places. Now, I'll preview this and look at the fourth column to confirm that the quantity and price have been multiplied together and the amounts have dollar signs in front of them. Something to note, keychain expressions can be placed anywhere in the report and don't have to specifically be in a table component.