Good afternoon, it is necessary that in the end there is not a sum, but the average of all values. Is it possible to implement this functionality?
Asked
Active
Viewed 130 times
0
-
Please provide enough code so others can better understand or reproduce the problem. – Community Feb 16 '22 at 13:54
1 Answers
0
In WDR, there is no clear way to make an average grand total if subtotal values contain the sum aggregations. But you can change the text in grand total cells with the customizeCell function to make it contain an average value. Example:
<!DOCTYPE html>
<html>
<head>
<title>WDR</title>
</head>
<body>
<link href="https://cdn.webdatarocks.com/latest/webdatarocks.min.css" rel="stylesheet" />
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.toolbar.min.js"></script>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.js"></script>
<div id="wdr"></div>
<script>
var pivot = new WebDataRocks({
container: "#wdr",
toolbar: true,
customizeCell: customize,
report: {
dataSource: {
filename: "https://cdn.webdatarocks.com/data/data.csv"
}
}
});
function customize(cell,data) {
if(data.isGrandTotalRow) {
cell.text = data.value / (data.rowIndex - 1);
}
}
</script>
</body>
</html>

Maxym Diachenko
- 11
- 1