KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Summary within a datastore #1869

Open Richb201 opened this topic on on Jan 25, 2021 - 2 comments

Richb201 commented on Jan 25, 2021

I have a datastore:

$year=$_SESSION['TY'][$key-2];
Table::create(array(
    "dataStore"=>$this->dataStore("srat")->filter("taxyear","=",$year),  //two years ago
    "showFooter"=>true,
    "columns"=>array(
        "taxyear",
        "qualified_dollars"=>array(
            "cssStyle"=>"text-align:right",
            "prefix"=>"$",
            "footer"=>"sum",
            "footerText"=>"<b>Total Wages Qualified:</b> @value"
        )
    ),
    "cssClass"=>array(
        "table"=>"table-bordered table-striped table-hover"
    )
));

What I'd like to do is show a summary for each of the last 3 years. Can I do this?

Taxyear                                                                                                Qualified_dollars
201604                                                                                                       $300  
201504                                                                                                       $200  
201404                                                                                                       $100

All the data is in a single datastore:

       $sql="
        SELECT taxyear, employee_email, employee_title, cost_center_name, consultant, w2_wages, qualified_dollars
        FROM survey_results_activities_temp
        ";
        $this->src('substantiator')
            ->query($sql)
            ->pipe($this->dataStore("srat"))  ;

If you could recommend a way to attack this problem, I'd appreciate that.

KoolReport commented on Jan 27, 2021

Yes of course, you can do this:

$sumSale = $this->dataStore("srat")->filter("taxyear","=",$year)->sum("saleAmount");

So basically you will get total sum of sale for the year you want.

Richb201 commented on Jan 27, 2021

Thanks. I managed to get it working correctly. I'd like to subtotal two separate tables.

For example is there a way to have both these table appear as a single table so I could total the totals? Which in this case would be $301,117? This could be in an additional column called GRAND TOTAL.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None