Skip Navigation

[Resolved] How to calculate sum of custom numeric field with group by in view

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by insooJ 6 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#746219
results.PNG
example.PNG

Tell us what you are trying to do?

I'd like calculate custom fields in view with DISTINCT , GroupBY
For example,

id buyer seller product amount
----- ------ ------- ------ ------
1 A X tv 100
2 B X tv 50
3 A X tv 200
4 B X radio 300
5 B Y radio 400

I want the results like below .

1) DISTINCT product
: tv
radio

2) sum groupby product per buyer

buyer product sum count
-------- ------------ ------ -------
A tv 300 2
B tv 50 1
B radio 700 2

How can I get them?

Best regards,
Insoo

#747935

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - There is no native feature available to group by custom field values, you need to write custom shortcocde.

However - I've one example to share with you (not exactly as you want but this will give you idea) which may help you:
=> https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/
[Check with above link how posts are grouped by year and month]

This needs custom programming for this which is beyond the scope of our support policy. If you need custom programming for your project, please feel free to contact our certified partners:
=> https://toolset.com/toolset-support-policy/

#748166

Thank you for your effort.