c5d90ac0bb781e34b7e4aa8f921f37d40945fa8c
API/CodeSamples/AggregateFunctions.md
| ... | ... | @@ -0,0 +1,56 @@ |
| 1 | +#AggregateFunctions |
|
| 2 | + |
|
| 3 | +[[_TOC_]] |
|
| 4 | + |
|
| 5 | +##About |
|
| 6 | + |
|
| 7 | +This collection is used to store custom-built aggregation function definitions. By default, this list will add onto the pre-existing set of aggregate function definitions. It will not override the pre-built functions. To access your custom-built aggregate functions, simply click on the [[Fields Tab]] of the Report Designer and select a column that can support your aggregate function. It will appear in the list of functions at the very bottom. There are a variety of methods for [[implementing a custom aggregate function|/FAQ/Questions/Custom_Aggregate_Functions]]. |
|
| 8 | + |
|
| 9 | +##Global.asax (C♯) |
|
| 10 | + |
|
| 11 | +```csharp |
|
| 12 | +//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 13 | +public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig |
|
| 14 | +{ |
|
| 15 | + // Configure settings |
|
| 16 | + // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method |
|
| 17 | + public static void InitializeReporting() { |
|
| 18 | + //Check to see if we've already initialized. |
|
| 19 | + if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null) |
|
| 20 | + return; |
|
| 21 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"; |
|
| 22 | + //Creates a connection to Microsoft SQL Server |
|
| 23 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"; |
|
| 24 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig(); |
|
| 25 | + AdHocSettings.AggregateFunctions["Group By Fiscal Year"] = new SimpleAggregateFunction("DATEPART(yyyy, DATEADD(mm, 3, {0}))", "Group (Fiscal Year)", new SqlTypeGroup[] { SqlTypeGroup.Date, SqlTypeGroup.DateTime }, true, true); //The relevant setting |
|
| 26 | + HttpContext.Current.Session["ReportingInitialized"] = true; |
|
| 27 | + } |
|
| 28 | +} |
|
| 29 | +``` |
|
| 30 | + |
|
| 31 | +##Global.asax (VB.NET) |
|
| 32 | + |
|
| 33 | +```visualbasic |
|
| 34 | +'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 35 | +Public Class CustomAdHocConfig |
|
| 36 | + Inherits Izenda.AdHoc.DatabaseAdHocConfig |
|
| 37 | + |
|
| 38 | + Shared Sub InitializeReporting() |
|
| 39 | + 'Check to see if we've already initialized |
|
| 40 | + If HttpContext.Current.Session Is Nothing OrElse HttpContext.Current.Session("ReportingInitialized") IsNot Nothing Then |
|
| 41 | + Return |
|
| 42 | + 'Initialize System |
|
| 43 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE" |
|
| 44 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE" |
|
| 45 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = New CustomAdHocConfig() |
|
| 46 | + AdHocSettings.AggregateFunctions("Group By Fiscal Year") = new SimpleAggregateFunction("DATEPART(yyyy, DATEADD(mm, 3, {0}))", "Group (Fiscal Year)", new SqlTypeGroup() { SqlTypeGroup.Date, SqlTypeGroup.DateTime }, True, True) 'The relevant setting |
|
| 47 | + HttpContext.Current.Session("ReportingInitialized") = True |
|
| 48 | + End Sub |
|
| 49 | +End Class |
|
| 50 | +``` |
|
| 51 | + |
|
| 52 | +##Screenshots |
|
| 53 | + |
|
| 54 | +**The Group By Fiscal Year Function** |
|
| 55 | + |
|
| 56 | +![]() |
|
| ... | ... | \ No newline at end of file |