KoolReport's Forum

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

Help Filter with defined parameters #737

Open Daniel Amamoo-Otchere opened this topic on on Mar 11, 2019 - 3 comments

Daniel Amamoo-Otchere commented on Mar 11, 2019

Hello, I have a parameter defined and will like to apply the filter tool to it. How do I go about it. The parameters will come from the following list

protected function defaultParamValues()
{
    return array(
        "parameter1"=>(2,3,4),
        "parameter2"=>(100,200,300), 
    );
}
->pipe(new Filter(array(
    array("analyte","in",parameter1),
   "and"
  array("sample_id","<",parameter2)

)))

I also saw this under the datasource documentation.

$store = $this->dataStore("data")
        ->filter(function($row){
            return $row["income"]>50000;
        });

How will that also be implemented correctly for my senario

Please advice on the format

KoolReport commented on Mar 11, 2019

You do this:

protected function defaultParamValues()
{
    return array(
        "parameter1"=>array(2,3,4), // it should be array()
        "parameter2"=>array(100,200,300), 
    );
}

and then in the setup()

->pipe(new Filter(array(
    array("analyte","in", $this->params["parameter1"]),
    array("sample_id","<",$this->params["parameter1"][0]) // I take the first value which is 100
)))
Daniel Amamoo-Otchere commented on Mar 14, 2019

Hello Team, From your sample you are using Parameter1 for the 2nd option which is not the scenario. The parameters are completely distinct. Thus can you use an "in" operatior for the second one also instead of the "<" symbol as shown in the block statement?

->pipe(new Filter(array(
    array("analyte","in", $this->params["parameter1"]),
    array("sample_id","in",$this->params["parameter2"][0]) // I take the first value which is 100
)))
KoolReport commented on Mar 14, 2019

Sure, so it would be like this:

->pipe(new Filter(array(

array("analyte","in", $this->params["parameter1"]),
array("sample_id","in",$this->params["parameter2"])

)))

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
solved

None