tracking - InitMetrics 

Page / - last modified by Outhman Moustaghfir on 2024/02/01 17:22 

InitMetrics 
last modified by Outhman Moustaghfir
on 2024/02/01 17:22

Table of Contents
InitMetrics Function Documentation
Overview
Usage
Request Parameters
Usage Examples
Notes

 
InitMetrics Function Documentation
Overview
The InitMetrics function provides functionality to initialize metrics in a flexible way. It allows for the deletion of metrics, projections, and the initialization of projections with fixed values or XPath expressions.
Usage
<xsl:value-of select="ixf:InitMetrics('Metric','Projection','Value')"></xsl:value-of>
Request Parameters
 1.	metricName (Required): The alias of the metric to be manipulated.
 2.	projection (Optional): The specific projection within the metric. If provided:
•	If value is not provided, the specified projection will be deleted.
•	If value is provided, the projection will be initialized with either a fixed value or an XPath expression.
 3.	value (Optional): The value used for initialization. Depending on the context:
•	If projection is provided, value initializes the projection.
•	If value is not provided, the specified projection is deleted.
 4.	defaultValue (Optional): The default value used in case of XPath expression evaluation failure. Defaults to 0 if not provided.
Usage Examples
Remember to adapt the metric names, projection names, and values based on your actual scenario. The provided examples are placeholders, and you should replace them with your specific metric, projection, and values.
Delete Metric:
<xsl:value-of select="ixf:InitMetrics('YourMetricName')"></xsl:value-of>
Example using Fixed Value:
Assuming you want to initialize a projection named 'YourProjection' in the metric 'YourMetric' with a fixed value of 42:
<xsl:value-of select="ixf:InitMetrics('YourMetric', 'YourProjection', '42')"></xsl:value-of>
 
This example initializes the 'YourProjection' projection in the 'YourMetric' metric with the fixed value of 42.
Example using XPath Expression:
Assuming you want to initialize a projection named 'YourProjection' in the metric 'YourMetric' with an XPath expression 'Order[Company = 'HM']' and a default value of -1:
<xsl:value-of select="ixf:InitMetrics('YourMetric', 'YourProjection', 'Order[Company = 'HM']', -1)"></xsl:value-of>
This example initializes the 'YourProjection' projection in the 'YourMetric' metric with the provided XPath expression. If the XPath expression fails to evaluate, it uses the default value of -1.
Notes
•	If projection is not provided, the entire metric is deleted.
•	If value is not provided, the specified projection is deleted.
•	The defaultValue parameter is optional and only applicable when initializing projections with XPath expressions.