When doing a PointInPolyJoin, there is the Join object key with method, table, and Where clause. Use Having to specify aggregate Where clauses (using the same format as normal Where blocks) that will filter results based on the post-join aggregate values (sum, avg, count).
<script type="text/javascript" src="/JS"></script><script type="text/javascript"> ml.onload(function () { var county = { query: { table: { name: 'census/BlockGroup' }, select: { type: 'geo.poly' }, where: [{ col: 'census/BlockGroup.inc', test: 'Greater', value: 60000 }], join: { method: "PointInPolyJoin", table: "hms/hotels", where: [ //where contains hilton && 3 star [ { col: "ChainID", test: "Contains", value: "hilton" } ], //OR where contains marriott && 3.5 star [ { col: "ChainID", test: "Contains", value: "marriott" } ], //OR [ { col: "LowRate", test: "Less", value: 15000 } ] ], having: [ { col: "LowRate.avg", test: "Greater", value: 100 } ] } }, style: { //having clauses (totals on grouped points) are supported using the intervals method for shading //(see below) //however, free form rules using having clauses are not supported yet //so for now you can't do this, but this feature is on our api road map //having:[col:'hms/hotels.LowRate.avg', test:'Greater' value:100] //if you need this feature ASAP contact our development team for a custom build quote method: 'interval', shadeBy: "hms/hotels.LowRate.avg", //count, sum, avg colors: [ { min: 'LightBlue-128', max: 'Blue-128' }, { min: 'Blue-128', max: 'Red-128' } ], ranges: [ { min: 0, max: 75 }, { min: 75, max: 150 } ] }, onHover: function (data, layer) { return "Avg. Low Rate: $" + Math.round(data.subTotals.LowRate.avg); }, //listing the hms/hotels table here is mandatory because we have two tables //.avg represents the average of the "LowRate" column points in this County hoverFields: ['hms/hotels.LowRate.avg'], onClick: 'debug' //when you click debug notice the shape data is under data.data //and how the point totals are under data.subTotals }; //create a new div and add to document //you could also fetch the element by id var div = ml.create('div', "width:100%; height:100%;", document.body); var map = new ml.map(div, { lat: 34, lng: -84, z: 5 }); var layer = new ml.layer(map, county); layer.show(); }); </script>