Problem/Motivation

Meta issue to track and solve related issues about calculations / display done wrong due to different decimal / thousands separator not using the universal notation.

e.g. 1 234.56 (English) would be written as 1.234,56 (German). Summing that up in this module leads to wrong values.

Current workaround: Use the english notation

Steps to reproduce

Proposed resolution

  • Add a setting for the table to define decimal and thousands separator
  • Or better: Use the setting from the numeric field that's being summed.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

anybody created an issue. See original summary.

anybody’s picture

Issue summary: View changes
anybody’s picture

@maintainers: Could you maybe explain a bit how the module handles numeric values and if (or why not) raw values are used?
Currently this seems unusable for non-default number formattings used in the view output, as described in the example.

We'd like to help, but it would be great to have a better starting point on how and where this should be fixed and which impediments you see. Thank you!

tr’s picture

I was not involved in writing that code and I don't know what the original intent was for how to handle number formatting. I would have to first try to reproduce this problem then figure out what to do about it. Usually, formatting numbers would be something done as late as possible, because this is essentially just theming/presentation and could differ on a per-user/per-page/per-view basis.

Since you already have a site set up that uses a different number format, you are in a better position to create a test case that demonstrates the problem. That is the first step in finding a solution. If you can do that, it would go a long way towards getting this fixed.

mortona2k’s picture

MR36 fixes the issues with number formatting with decimals/commas: https://www.drupal.org/project/views_aggregator/issues/3482129

To test, I added a decimal field to the article content type in the standard install profile, and generated content with devel generate.

Then I created a view that lists article titles and the decimal field, formatted with views aggregator.

Group sum:
Views aggregator group sum formatted decimal

Column sum:
Views aggregator column sum formatted decimal

There are a handful of options to test, like enabling prefix/suffix, which is configured in the field settings.

grevil’s picture

StatusFileSize
new10.52 KB

For me it works great out of the box! I am only using the patch from https://git.drupalcode.org/project/views_aggregator/-/merge_requests/37

I adjusted my decimal fields view settings to have the "decimal dot" as the "thousand separator", and a "comma" as my "decimal point" representation and the output is as expected (including the sum):
screenshot

To be fair I don't do any complex calculation or grouping, so there might be still issues when displaying decimal numbers.