CreateReport
Generates a custom analytics report by specifying desired dimensions, metrics, segments, and time range.
Stored Procedure Specific Information
Use the CreateReport stored procedure to generate a custom static report. This procedure provides a way to generate new view definitions with a custom combination of dimensions and metrics. Calling it creates a new schema file that you can query like any other view.
You must set the Location connection property to the folder containing the new script files in order to access them.
You can retrieve metric and dimension Ids by querying the Metrics and Dimensions views. For example:
SELECT Id, Name FROM Dimensions SELECT Id, Name FROM Metrics
To include calculated metrics in your report, you can retrieve the metric Id by running the following query:
SELECT Id, Name FROM CalculatedMetrics
To use a new schema along with the default schemas, set the Location property to the db subfolder in the installation folder. Then you can make any of the following calls:
EXEC CreateReport DimensionIds = 'variables/geocountry, variables/geocity', MetricIds = 'metrics/pageviews, metrics/visits', TableName = 'MyCustomReport' EXEC CreateReport DimensionIds = 'variables/geocountry, variables/geocity', MetricIds = 'metrics/pageviews, metrics/visits', TableName = 'MyCustomReport', DefaultDateRage = '2025-01-01/2025-01-30' EXEC CreateReport DimensionIds = 'variables/geocountry, variables/geocity', MetricIds = 'metrics/pageviews, metrics/visits', TableName = 'MyCustomReport', DefaultDateRage = '2025-01-01/2025-01-30', DefaultSegmentId = 's3642_649ae61b5a255650b8391f9d'Note that dimensions and metrics must have their respective Ids specified in the DimensionIds and MetricIds inputs.
Input
| Name | Type | Required | Description |
| TableName | String | True | The name for the new table. |
| Description | String | False | An optional description for the table. |
| WriteToFile | String | False | Specifies whether to write the contents of this stored procedure to a file. The default value is true. Set to false to return file data through FileStream or FileData. |
| DimensionIds | String | True | A comma-separated list of dimension Ids. |
| MetricIds | String | True | A comma-separated list of metric Ids. |
| AllowOverride | String | False | When WriteToFile is set to true and a file with the same name already exists, this parameter specifies whether the file should be overwritten.
The default value is false. |
| DefaultDateRage | String | False | The date range that is used as the default when executing the created report. If the date range is not specified, a range of 2 years is applied up to the date the report is executed. This value can be overridden when executing the report by specifying the StartDate and EndDate parameters. The accepted format is StartDate/EndDate (for example, 2023-01-01/2023-12-31). |
| DefaultSegment | String | False | An optional default segment to add to the report. Only one value is allowed. |
Result Set Columns
| Name | Type | Description |
| FileData | String | The generated schema file as a base64 string if WriteToFile is set to false; null otherwise. |
| Success | String | Specifies whether the schema was created successfully. |
| SchemaFile | String | The generated schema file path if WriteToFile is set to true; null otherwise. |