Using AGGR to resolve a "Sum of Rows" issue
"Sum of Rows" issues are reasonably rare. Essentially, what it means is that the sum that is displayed as the total on a table is not actually the sum of the rows displayed in the table (usually discovered when exporting to Excel), or the total is not calculated at all. Often, it can be the result of a complicated if
statement in the expression, or from using values from across different tables in the expression.
In this recipe, we will look at a very simple example and see how to resolve it using AGGR
.
Getting ready
Load the following script:
// Load Sales data Sales: LOAD * INLINE [ Country, Month, Curr, ProdID, Price, Qty USA, 2013-01-01, USD, 1, 1.99, 2 USA, 2013-02-01, USD, 2, 2.99, 3 USA, 2013-03-01, USD, 1, 1.98, 5 UK, 2013-01-01, GBP, 1, 1.59, 1 UK, 2013-02-01, GBP, 1, 1.58, 3 UK, 2013-03-01, GBP, 1, 1.58, 3 UK, 2013-03-01, GBP, 1, 1.58, 3 ]; // Load Exchange Rates LOAD * INLINE [ Curr, ExRate USD, 1 GBP, 0.63 ];