I have a super table that has 4 columns. I'm trying to create an array based off one column (contentType
) and merges to get only the unique values while taking the sum of a different column (points
). Here is a screen shot:
Based off that screenshot I would have the following results:
- Motivation-To-Achieve : 2
- Emotional-Stability : 2
- Openness : 4
I'm able to get the unique content types, however, I can't figure out how to take the sum of the points column. This is what I have so far:
{% set results = {} %}
{% for row in entry.surveyData %}
{% set type = row.contentType %}
{% set pts = row.points %}
{% set results = results|merge({ (type) : {'name': type, 'points': pts } }) %}
{% endfor %}