KoolReport's Forum

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

Calculation from different queries #95

Open tee opened this topic on on Aug 28, 2017 - 5 comments

tee commented on Aug 28, 2017

Hi support team,

Is it possible to have calculation on table's column of report.view? The purpose is to allow me to have calculation for particular columns from two queries. Example, Total=$variable1+$variable2. Both variables are shown below. Appreciate you.

$variable1 = $this->dataStore("qry1")->data()[0]["sales1"];
$variable2= $this->dataStore("qry2")->data()[0]["sales2"];
KoolReport commented on Aug 28, 2017

Could you please add some images to illustrate your need?

tee commented on Aug 28, 2017

Based on the table above showing a column of Sales with its multiple rows of data from the query. The way that i did was by using CalculatedColumn, this process works fine since sales and sales_percent are from same data store.

->pipe(new CalculatedColumn(array(
            "Sales"=>array(
                "exp"=>function($data){
                    return $data["sales"]."<br>".$data["sales_percent"];
                },
                "type"=>"string",
            ),
          )))

My problem is how could i use the same way to return $data[] from different data store? Let say sales_percent is from another data store. Thanks.

KoolReport commented on Aug 28, 2017

I think you should join two flows of data into one. Is there any connection between them, for example they have the same id.

tee commented on Aug 28, 2017

Unfortunately both have no connection. Or else i could done this process on the view by using the code in my first comment to call out two variables from different data store? Thanks.

KoolReport commented on Aug 28, 2017

Hi tee,

Frankly I have not been able to imagine your data, data flows and how you want to calculate and display result. If you could show me code or image in more details, I can guide you more precisely.

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
help needed

None