Aggregate Functions

Top Previous Topic Next Topic  Print this topic

Aggregate Functions are functions that compute values over all records in a data source.

 

The following aggregate functions are supported:

 

count - Returns the number of records in a data set.

max - Iterates over the specified data source and computes the maximum value of the referenced source.

min - Similar to max except it computes the minimum value.

average - Similar to max except it computes average value from the specified source.

sum - Similar as max except it computes sum from the specified source.

 

The sample below demonstrates all the supported aggregate functions and returns the record count, and the maximum, minimum, average and sum of hours worked from data in the Hist table.

 

Aggregate-Functions

 

Note: This sample is called AggregateFunctions.dax and it can be found in the Samples\Job Samples folder.

 

OUTPUT:

 

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<ns:root xmlns:ns="http://www.tempuri.org/XML">

       <ns:count>7</ns:count>

       <ns:max-hours-worked>8000</ns:max-hours-worked>

       <ns:min-hours-worked>100</ns:min-hours-worked>

       <ns:average-hours-worked>2557</ns:average-hours-worked>

       <ns:sum-hours-worked>17900</ns:sum-hours-worked>

</ns:root>