Dynamic updates of calculated data
Another advantage of column bindings becomes apparent when working with calculated data. When a report needs to display a series of related calculated data, column bindings enable you to create and update calculations easily. For example, assume a report contains the following four data elements:
*The first data element uses column binding, Order_Total, which uses the SUM function, and the following expression to calculate the sum of all order line items:
dataSetRow["pricequote"] * dataSetRow["quantity"]
*The second data element uses column binding, Sales_Tax, which refers to the previous column binding, Order_Total, to calculate the sales tax. The expression defined for the Sales_Tax column binding is
row["Order_Total"] * 0.08
Without using column bindings, the second data element must use the SUM function and the following longer expression to calculate sales tax:
(dataSetRow["pricequote"] * dataSetRow["quantity"]) * 0.08
*The third data element uses column binding, Shipping_Charge, which also refers to the first column binding, Order_Total, to calculate the shipping charge. The expression defined for the Shipping_Charge column binding is
row["Order_Total"] * 0.02
Again, without using column bindings, the third data element must use the SUM function, and the following lengthier expression to calculate the shipping charge:
(dataSetRow["pricequote"] * dataSetRow["quantity"]) * 0.02
*The fourth data element uses column binding, Invoice_Total, which refers to all the previous column bindings to calculate the grand total. The expression defined for the Invoice_Total column binding is
row["Order_Total"] + row["Sales_Tax"] + row["Shipping_Charge"]
Without column bindings, the expression would be more complicated:
(dataSetRow["pricequote"] * dataSetRow["quantity"]) + ((dataSetRow["pricequote"] * dataSetRow["quantity"]) * 0.08) +
((dataSetRow["pricequote"] * dataSetRow["quantity"]) * 0.02)
You have already seen how column bindings make expressions shorter and more readable. Now, consider the case where you need to update one calculation that is used by other calculations. Suppose you need to change how Order_Total is calculated, from:
dataSetRow["pricequote"] * dataSetRow["quantity"]
to:
(dataSetRow["pricequote"] * dataSetRow["quantity"]) - dataSetRow["discount"]
Because the second, third, and fourth data elements use Order_Total in their calculations, without using column bindings, you must manually edit those calculations as well. For example, without using column bindings, you would have to revise the expression for the fourth element as follows:
((dataSetRow["pricequote"] * dataSetRow["quantity"]) - dataSetRow["discount"]) +
((dataSetRow["pricequote"] * dataSetRow["quantity"]) * 0.08) + ((dataSetRow["pricequote"] * dataSetRow["quantity"]) * 0.02)
By using column bindings, any change to the first calculation automatically applies to the second, third, and fourth calculations. By modifying only one expression instead of three, your work is faster and less error‑prone.