CurrencyConvert(Weighted(amount;probPercent);currencyId))
Scenario 1
To demonstrate the concept, construct a query that displays the top sales representatives this month. Do this by specifying a restriction where theuserGroup equals the sales group, the saleStatus is sold, and the sale date is within the past month. Sort the results by the sum of the sale amount, descending. Then add the following aggregate functions to display the results in a footer - one for each distinct group:
- using
SumandConvertCurrency, convert all sale amounts to one currency and then sum the amounts. - use
GroupByto divide the results by full name, personId, and title.
The
CultureDataFormatter method is used to format the summed amount into local currency in both the footer and grandtotal rows.Query results
Scenario 2
Another common scenario to demonstrate nested functions is to group sales based on aDatePart. Combined with a GroupBy, the use of DatePart makes it easy to aggregate sales by week, month, or quarter.
Use the previous example as a template and modify the restriction sale date to show just this year. Modify the Sort to use the GroupBy DatePart, ascending. Then change the desired columns to just include the Sum of sale amounts and a GroupBy to divide the results by months.