Question:

Is it possible to create a chart by grouping based on Invoice value. Say 1000 to 2000, 2000 to 5000 and > 5000 and display the number of invoices and total value.

Answer:

You may use the NumberRange and Group process to do

$this->src("database")->query("
    SELECT amount FROM invoices
")
->query(new CopyColumn(array(
    "group_amount"=>"amount",
    "number_invoice"=>"amount"
)))
->pipe(new NumberRange(array(
    "group_amount"=>array(
        "<1000"=>array(-INF,1000),
        "1000-2000"=>array(999.99,2000), // 1000<= a <2000
        "2000-5000"=>array(1999.99,5000), // 2000<= a <5000
        ">5000"=>array(4999.99,INF) // 5000 <= a
    )
)))
->pipe(new Group(array(
    "by"=>"group_amount",
    "sum"=>"amount",
    "count"=>"number_invoice",
)))