The community of Analytics developers are invited to follow and participate in the developer network.
OpenText technical experts collaborate with supported customers and partners in the Magellan product area.

Not able to Filter the Report Data based on Year

I need to filter the report data in BIRT based on the year selected in the report parameter. If I select 'Current Year' from the parameter, it should only return me the data for 2020 year and not previous year. 

Please find the attach screenshot for the report result I'm getting. I have applied the filter for 'Planned Start' field to check if it's for current year. Please find the below condition that I have written for filtering on dataset.

var cy = BirtDateTime.year(BirtDateTime.today());
var py = BirtDateTime.year(BirtDateTime.today())-1;
var c  = row["triTask__triWorkTask____triPlannedStartDT"];
var b = new Date(Formatter.format(row["triTask__triWorkTask____triPlannedStartDT"],"dd/mm/yyyy"));
var a = BirtDateTime.year(b);
if (params["Year"].value == 'Current Year')
{
     if(a==cy)
     {true}
}
if (params["Year"].value == 'Previous Year')
{
     if(a==py)
     {true}
}

Please suggest me if I'm doing anything wrong here.


Comments

  • Try changing var b to:
    var b = Formatter.format(row["triTask__triWorkTask____triPlannedStartDT"],"yyyy-MM-dd");

    It would also be good to check row["triTask__triWorkTask____triPlannedStartDT"] for nulls.


    Regards,
    Jeff F.
    Sr. Technical Support Specialist
    OpenText
  • you  can also filter query on data set directly 
    select * from employee where department=DEPARTMENT
    replace this DEPARTMENT on dataSet beforeOpen at Script
Sign In or Register to comment.