Skip Navigation

[Resolved] select sum custom field group by another custom field

This support ticket is created 7 years, 5 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.

Our next available supporter will start replying to tickets in about 1.97 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by ahmedA-7 7 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#536359

In <wpv-loop> I am trying to do this query, " select sum (wpfc-conuts) GROUP BY (wpfc-comment-type) "

How creat shortcode for this function ?

I followed up this https://toolset.com/forums/topic/calculating-types-custom-fields-and-display-in-html-container/

It's work nice but I can not GROUP BY field 🙁

the result come like this :
---------------------------------
5 - Thanks
1 - Survey
1 - Help
1 - Help
1 - Compliment
2 - Comment
1 - Comment
1 - Comment
1 - Comment
1 - Comment
4 - Comment

Total = 19
---------------------------------

and I need result group by wpcf-comment-type like this:
--------------------------------
5 - Thanks
1 - MOPH Survey
2 - Help
1 - Compliment
10 - Comment

Total = 19
-------------------------------

#536506

Dear Ahmed,

I suggest you create the view filter by shortcode attribute, manually output the group result, for example:
Thanks: [wpv-view ... comment-type='Thanks']
MOPH Survey: [wpv-view ... comment-type='MOPH Survey']
...
See our document:
https://toolset.com/documentation/user-guides/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes
Controlling the filter with shortcode attributes

#536578

Thank you for your reply, can you explanation how can use this:
-----------------------

Thanks: [wpv-view ... comment-type='Thanks']
MOPH Survey: [wpv-view ... comment-type='MOPH Survey']

----------------------

please give me step by step .

Thank you

#536941

You can edit your view, in section "Query filters", add a Custom field filter:
Select items with field:
comment-type is a string equal to VIEW_PARAM(commenttype)

Then use shortcode in content

-----------------------

Thanks: [wpv-view ... comment-type='Thanks']
MOPH Survey: [wpv-view ... comment-type='MOPH Survey']

----------------------

https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/#2
Shortcode attribute
The value for the filter comes from an attribute in the View shortcode
You’ll be able to insert the same View in different places and control content filtering via the View Shortcode.

#537130

Thank you a lot 🙂 I have note:

commenttype='Thanks' <== like this its working fine

comment-type='Thanks' <== like this Not working

with ( - ) not working because its must same VIEW_PARAM(commenttype)