ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: EPM Solutions on February 11, 2020, 05:22:19 pm

Title: How can we calculate Custom row summary calculation conditionally?
Post by: EPM Solutions on February 11, 2020, 05:22:19 pm
Hello Team,

Requirement:
Exclude the records where Applicable column has No value from an avg(Custom row summary);

Can you please provide an example to calculate custom row summary for above requirement?

We have added an snippet in below URL;
Problem URL:
http://next.plnkr.co/edit/nCDCvzvt7eihojGl
Title: Re: How can we calculate Custom row summary calculation conditionally?
Post by: paramvir on February 26, 2020, 11:52:29 am
Please check this solution: https://stackblitz.com/edit/custom-aggregates

Code: [Select]
  var agg = pq.aggregate;
  agg.avgCustom = function(arr, col, rows) {   
    var vals = arr.filter(function(val, i){
      return (rows[i].applicable || "").toUpperCase() != "NO"
    })
    return agg.avg(vals, col)
  };