• Resolved madrugadora

    (@madrugadora)


    Hello,

    I have a query with details of user registration and payment details to an event, and I need to get the sum of the payment amounts, but filtering by different columns (nationality, age, etc.) I would like the user to do the filtering directly on the report.

    Is there any way to have the SUM query, and do the grouping depending on the filters? I guess if it can be done it has to do with the “related group by” on the custom fields, but I don’t know how to use it.

    Thank you in advance and regards,

    María.

    https://wordpress.org/plugins/exports-and-reports/

Viewing 1 replies (of 1 total)
  • Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    You can use subqueries in the SELECT to get a SUM from a separate set, but just be sure to use the placeholders as described in the Query textarea description.

    If you are looking to show a SUM of all of the data on the current page, that’s something I’ve looked into and it won’t be available in this plugin any time soon, it’s a very tricky feature that’s taken a bit more time and thought than I have to finish it.

    We don’t have custom grouping by filters, that’s definitely not possible in any other way currently, unless you filter the query yourself and try and inject your own filtering.

    You can filter the options in Exports and Reports 0.6.4 with the new filter exports_reports_report_options which you will want to override the $options['sql'] with whatever you want. You can probably create your own “placeholder” in that part of the query like %%MY_CUSTOM_PLACEHOLDER%% and just replace it in your filtering.

Viewing 1 replies (of 1 total)

The topic ‘Filtering query with SUM’ is closed to new replies.