Not able to Filter the Report Data based on Year

mihika.shah
edited February 11, 2022 in Analytics #1
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.


    Warning No formatter is installed for the format ipb
  • you  can also filter query on data set directly 
    select * from employee where department=DEPARTMENT
    replace this DEPARTMENT on dataSet beforeOpen at Script