0

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?

Blitz
  • 1
  • 1

1 Answers1

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>