Comparing the count of two flags to show a percentage difference

Created on 18 October 2024, 2 months ago

I have added two flags relationships in to the view then created the two flag fields with the title.

I now have a table that looks like this:

TITLE | Flag Count 1 | Flag Count 2
Food 12 3

I want to add a fourth column, simple math field and show the difference between the two flag counts by percentage.

I set that up and using this expression

(@count / @count_1) * 100

Now the table completely vanishes and nothing shows for it, why?

I even try

@count + @count_1

Doesn't add the two columns/fields together.

πŸ’¬ Support request
Status

Active

Version

3.0

Component

User interface

Created by

πŸ‡¬πŸ‡§United Kingdom effortDee

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @effortDee
  • πŸ‡ΊπŸ‡ΈUnited States andileco

    Hi @effortdee - unfortunately, the way this specific Views field (Counter) is constructed, the value it returns is a string containing Twig: "{{ counter }}", and this gets rendered after the Views Simple Math Field has already performed its calculation. Can you instead aggregate your view and use the COUNT aggregation method and use the field you've applied that on in your Views Simple Math Field?

Production build 0.71.5 2024