【Query Builder：Expression】Refer to columns in the current row of query results

Among the many Expressions provided by the [Sharperlight](https://sharperlight.com/) query builder, this time I will try using the syntax that refers to other columns in the same row, which is the basic of the basics.

Launch **Query Builder** from the application menu of [Sharperlight](https://sharperlight.com/).
Let's choose **Summary Report** for `Mode` and **SAP Business One** for `Product`.
For `Company`, **OEC Computers Australia** is fine. For the `Table`, let's select **Outgoing Payments**.
The default mandatory filters are set, but let's leave the values as they are and drag and drop the `Canceled` field from the Selection list to the Filter. Specify **N** for it.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/6c448190-1ed1-1af5-2d81-ecb8c07787e0.png)
Now let's move on to setting the output items.
From the Selection list, set the following fields to the Output area by double-clicking or dragging and dropping.
- Customer/Vendor Name
- Document Total

At this point, keep an eye on the attributes of the output items. Each item is automatically assigned a code prefixed with %.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/857f724c-b711-a381-04e4-39d82bd9f204.png)
These are called **Names** in Sharperlight and are used as unique **Reference Codes** within the Query Builder as well as other Sharperlight products. So if this reference code is used anywhere, be careful with this **name** change.
Renaming can be done from the right-click menu. If you change the name, all places where the name is referenced in the query will be automatically updated with the new name.

Now let's add an Expression which refers to a column in an output row, which is the subject of this article.
From the right-click menu in the output area, select **Add Expression** to launch the editor.
Expand **Current Row** from the list of functions in the editor. All items in the output area can be referenced in this way.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/721ba34c-7d08-3a20-b0ca-9bc47fe9b469.png)
After that, simply double-click to select the item you want to reference. Try selecting **Document Total**. You can see that the `Name` (Reference code) is used.
Please make sure the `Data Type` should be the same data type of the referencing column.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/82153a5e-e315-4f94-f394-8fe64939d463.png)
The output items are like this now.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/c4b93ba7-356e-9804-7ca0-82c71311fb7a.png)
Let's run the query with the `Preview` button.
You can see that the Expression column also displays the same value as the **Document Total** column.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/d7af3df2-d4c5-9e8f-549f-347c614aeaad.png)
This time I just referred to it, but it can be used for various calculations and expressions.
By the way, the column name of the Expression can be changed with its `Description` attribute.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/f208b2b1-76d1-a1fd-58a1-e26520b6d1bd.png)
or with the right-click menu.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/526494ca-15a4-6e61-dae8-2bb8d2199139.png)
e.g. like this.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/8c5477c7-02a9-cbc7-b177-5f3961db2bfc.png)