KoolReport's Forum

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

Filter numeric data using > and < operators not working properly #2235

Closed hsw opened this topic on on Jul 28, 2021 - 2 comments

hsw commented on Jul 28, 2021

Hi,

My datasource is a csv file.

Example of csv file data below:

"name","min","max"
"A",1500000,9999999
"B",500000,999999
"C",800000,999999
"D",150000,499999
Example of my Filter process:
   $amt = 600000;
   $source->pipe($this->dataStore("packages")); 
        $this->src('packages')
        ->pipe(new Filter(array(
			array("min","<=",(int)$amt),
			array("max",">",(int)$amt)
        )))

I expect only 1 row will be output: "B",500000,999999

But, it outputs 2 rows: "A",1500000,9999999 and "B",500000,999999 From what I see, the Filter is treating the "min" and "max" values as text. How do I make sure the min and max data is treated as integer?

Thank you.

KoolReport commented on Jul 28, 2021

You may use the ColumnMeta before Filter to ensure the type of min and max:

$this->src('packages')
->pipe(new ColumnMeta(array(
    "min"=>array("type"=>"number"),
    "max"=>array("type"=>"number"),
)))
...

Please let us know if it works.

hsw commented on Jul 29, 2021

Hi,

Thanks for your prompt advice. It is working fine now, after I included the ColumnMeta process.

Thank you :D

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