A RatioToReportAnalytic is an AnalyticFunction that determines the ratio of the current property value to the sum of the property value for the entire partition, returning the percent ranking as a Double. Values range from 0.0 to 1.0. The ratio to report is the percentage contribution this value makes towards the total of the property values. E.g. values of 2 3 4 5 6 receive ratios to report of 0.1 0.15 0.2 0.25 0.3.
Create and use a RatioToReportAnalytic, with one of the following methods:
AnalyticAggregator ana = new AnalyticAggregator.Builder() .setAnalyticFunction(new RatioToReportAnalytic(value1)) .setPartition(new PartitionClause(Arrays.asList("category1"))) .setOrderBy(new OrderByClause(Arrays.asList(new OrderByElement("value2", OrderByElement.SortDir.DESC)))) .build();
AnalyticAggregator agg = AnalyticAggregator.getAnalytic("RatioToReportAnalytic(value1) partitionBy(category1) orderBy(value2 DESC)");
RatioToReportAnalytic expects its property to have numeric values.
RatioToReportAnalytic is a DependentAnalyticFunction that computes the ratio to report with Sum(prop) rows(0, 0) / Sum(prop) range(), and it does not take a user-given window clause.