We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

Weighted Average Aggregation based on other column's values

Answered
Will Aguiraud asked 1 day ago

Hello,

 

We are looking into adding an aggregation type which would calculate a weighted average based on another column's weight values, instead of calculating a straight average as is currently supported by Flexmonster. I am attaching a screenshot of a table which shows what I'm referring to. i.e. A would be a sum of A1 and A2 weighted by their corresponding values in the Weights column, divided by the total weight.

So the calculation for A would be (1000 * 0.3 + 2000 * 0.6)/0.9 = 1,666.67.

Is there a way of doing that currently? If so, could you give us some pointers on how to achieve it? If not, could Flexmonster implement it? Thank you.

1 answer

Public
Maksym Diachenko Maksym Diachenko Flexmonster 17 hours ago

Hello, Will!

Thank you for writing to us.

Such a formula can be created with Flexmonster's calculated values - a feature for creating custom formulas based on existing measures. Assuming that your dataset contains individual fields with values, weights, and string hierarchies for "A" and "B", you can create a formula as is shown in this example: https://jsfiddle.net/flexmonster/0tw5f3xh/

Here is an explanation of this example:

  1. "value_x_weight" - values multiplied by weights. For correct output, this formula should multiply values individually, which can be flagged with individual: true. Also, since this is a part of the final formula, so it should be hidden with the active: false parameter.
  2. "weighted_avg" - the formula used for final visualization, which divides the "value_x_weight" on the sum of weights.

We are looking forward to hearing your feedback.

Best Regards,
Maksym

Please login or Register to Submit Answer