Weighted Average Aggregation based on other column's values

Answered
Will Aguiraud asked on October 16, 2024

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.

4 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster October 17, 2024

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

Public
Will Aguiraud October 23, 2024

Hi Maksym,

Thank you for your quick response. 

Following up to your response, is there a way to hide the value field so that the user doesn't have the option of displaying it at all? Also, is there a way to display some of the values that are under Calculated Values directly in the list, in the same way that other values such as name, type and weight are being displayed?

 

Best,

Will

 

 

Public
Maksym Diachenko Maksym Diachenko Flexmonster October 24, 2024

Hello, Will!

Thank you for your reply.

Both mentioned customizations can be implemented within Flexmonster. The "value" field can be hidden from the Fields List via CSS:

#pivot-container .fm-fields-view .fm-ui-list > [aria-label="value"] {
display: none;
}

Since all fields within the Field List use the "aria-label" attribute, this approach can be universally applicable for hiding any field independently from its position. To show calculated values on top of the Fields List and not in a folder, you can change the "Calculated values" folder name localization to an empty string.

Our team prepared a JSFiddle to illustrate both removing the "value" field and the "Calculated values" folder: https://jsfiddle.net/flexmonster/j63pr7xL/

Please let us know if these solutions work for you.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster 5 days ago

Hello, Will!

Hope you are doing well.
Please let us know if you had time to test the suggested configurations for modifying the visualization of values in the Fields List.
Looking forward to hearing your feedback.

Best Regards,
Maksym

Please login or Register to Submit Answer