Forums BIRT Reports Complex Filter Condition in BIRT

This topic contains 6 replies, has 3 voices, and was last updated by  ani_difranco 2 years, 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #126

    ani_difranco
    Participant

    Hello Team,

    I created a dataset where I have two columns called BuildingClass and EventDate. I want to filter the dataset results based on below criteria.

    if (BuildingClass ==’No’ || BuildingClass ==” || BuildingClass ==null)
    {
    EventDate < (CurrentMonth +18) —–18 months from now
    }
    else
    {
    EventDate < (CurrentMonth +36) ——36 months from now
    }

    Hence my dataset should be filtered based on EventDate value if BuildingClass condition is met.

    Please suggest how this can be possible. Thanks in advance!

    #127

    joe_dallesandro
    Participant

    ry the following for the condition and change the operator to “Is True”:

    var bc = row[“BuildingClass”];
    var ed = row[“EventDate”];

    if (bc ==’No’ || bc ==” || bc ==null) {
    if ( ed < BirtDateTime.addMonth(BirtDateTime.today(), 18) ) {
    true
    } else {

    false
    }
    } else {
    if ( ed < BirtDateTime.addMonth(BirtDateTime.today(), 36) ) {
    true
    } else {
    false
    }
    }

    #128

    ani_difranco
    Participant

    Thanks,for your quick response.

    I used below condition with operator as “Is True” as mentioned by you.

    var b=String(row[“Location__triBuilding____triBuildingClassCL”]);
    var d=Formatter.format(row[“triItem__triOption____triDateDA”],”MM/dd/YYYY”);
    var e;
    if( b==’No’ || b==” || b== null)
    {
    if(d < (Formatter.format((BirtDateTime.addMonth((Formatter.format(BirtDateTime.today(),”MM/dd/YYYY”)), 18)),”MM/dd/YYYY”)))
    {
    e=true;
    }
    else
    {
    e=false;
    }
    }
    e;

    For some reason, it still doesn’t give me the correct results. For example, a record with BuildingClass set as ” has two EventDates “05/31/2018” and “04/30/2015”. As per this condition, it should give me the results with date “04/30/2015” and filter out “05/31/2018” (as it exceeds 18 months of timeframe). But it gives the results exactly opposite to it i.e. gives me the results with date “05/31/2018” and filter out “04/30/2015”.

    I’m using Formatter as EventDate field value doesn’t have a timestamp with the date.

    Can you please check what can be wrong here?

    #129

    ani_difranco
    Participant

    Could you provide some sample data in a CSV or Excel file that we can test?

    #130

    ani_difranco
    Participant

    Hi joe,

    Please find the below sample data. Sorry I couldn’t attach the file.

    Event Date Building Class

    3/31/2015 No
    5/19/2018 No
    8/18/2016 Branch
    10/1/2018 Enterprise
    2/18/2017 No
    7/31/2014 Enterprise
    1/26/2019 No
    9/30/2015 Branch

    #131

    debbie_harry
    Participant

    I was breaking the condition into small peices just for testing and found that the condition for comparing the dates is not working as expected. It’s giving the dates even after 2019 though the timeframe is set as 18 months from now.

    Is it because my actual date field has type as Java object. And I’m formatting the date and getting the result.

    Can someone please look into this?

    #132

    ani_difranco
    Participant

    Thanks joe. I resolved the issue with the date comparision. My source date string was coming as Java Object data type as I’m using scripted data source. And hence when I used Formatter to change the date format, it returned me a string which wasn’t allow me to compare the dates. So I converted string to date using new Date() and it worked as expected.

    But right now when I run my report, it gives me java.lang.NullPointerException and below is the stack trace. I’m not able to find out any issues.

    java.lang.NullPointerException
    at org.eclipse.birt.core.archive.compound.ArchiveEntryOutputStream.flushBuffer(ArchiveEntryOutputStream.java:169)
    at org.eclipse.birt.core.archive.compound.ArchiveEntryOutputStream.write(ArchiveEntryOutputStream.java:125)
    at java.io.DataOutputStream.writeLong(Unknown Source)
    at org.eclipse.birt.core.util.IOUtil.writeLong(IOUtil.java:403)
    at org.eclipse.birt.data.engine.impl.document.RowSaveUtil.saveNullRowsBetween(RowSaveUtil.java:271)
    at org.eclipse.birt.data.engine.impl.document.RowSaveUtil.saveFinish(RowSaveUtil.java:215)
    at org.eclipse.birt.data.engine.impl.document.RDSave.saveFinish(RDSave.java:190)
    at org.eclipse.birt.data.engine.impl.ResultIterator$RDSaveHelper.doSave(ResultIterator.java:1258)
    at org.eclipse.birt.data.engine.impl.ResultIterator$RDSaveHelper.doSaveFinish(ResultIterator.java:1218)
    at org.eclipse.birt.data.engine.impl.ResultIterator.close(ResultIterator.java:971)
    at org.eclipse.birt.data.engine.impl.ResultIterator$1.dataEngineShutdown(ResultIterator.java:201)
    at org.eclipse.birt.data.engine.impl.DataEngineImpl.shutdown(DataEngineImpl.java:575)
    at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.shutdown(DataRequestSessionImpl.java:509)
    at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.shutdown(AbstractDataEngine.java:348)
    at org.eclipse.birt.report.engine.data.dte.DataGenerationEngine.shutdown(DataGenerationEngine.java:151)
    at org.eclipse.birt.report.engine.executor.ExecutionContext.close(ExecutionContext.java:496)
    at org.eclipse.birt.report.engine.api.impl.EngineTask.close(EngineTask.java:1539)
    at org.eclipse.birt.report.engine.api.impl.RunTask.close(RunTask.java:309)
    at org.eclipse.birt.report.service.ReportEngineService.runReport(ReportEngineService.java:1335)
    at org.eclipse.birt.report.service.BirtViewerReportService.runReport(BirtViewerReportService.java:158)
    at org.eclipse.birt.report.service.actionhandler.BirtRunReportActionHandler.__execute(BirtRunReportActionHandler.java:81)
    at org.eclipse.birt.report.service.actionhandler.BirtChangeParameterActionHandler.runReport(BirtChangeParameterActionHandler.java:58)
    at org.eclipse.birt.report.service.actionhandler.AbstractChangeParameterActionHandler.__execute(AbstractChangeParameterActionHandler.java:53)
    at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90)
    at org.eclipse.birt.report.soapengine.processor.AbstractBaseDocumentProcessor.__executeAction(AbstractBaseDocumentProcessor.java:47)
    at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.executeAction(AbstractBaseComponentProcessor.java:143)
    at org.eclipse.birt.report.soapengine.processor.BirtDocumentProcessor.handleChangeParameter(BirtDocumentProcessor.java:100)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.process(AbstractBaseComponentProcessor.java:112)
    at org.eclipse.birt.report.soapengine.endpoint.BirtSoapBindingImpl.getUpdatedObjects(BirtSoapBindingImpl.java:66)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
    at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
    at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
    at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
    at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.doPost(BirtSoapMessageDispatcherServlet.java:265)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.service(BirtSoapMessageDispatcherServlet.java:122)
    at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:318)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:939)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

    Please let me know if you can identify any issues from this stack trace.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.