Home Analytics Designing reports
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.

Unable to create dynamic parameter for current year and previous year

Hi All,

I am trying to create a BIRT report where I need a parameter which needs to show the current year and previous year as the value in the dropdown. For example, the parameter should show 2020 and 2019 as the values as per the current date and it should change next year and going forward. 

I'm using Scripted Data Source and Data Sets from my third party tool called IBM TRIRIGA. Please suggest any way of creating this parameter. Appreciate any help.
Tagged:

Comments

  • Create your parameters and use the following in the default value:
    Current year
    BirtDateTime.year(BirtDateTime.now())

    Prior year
    BirtDateTime.year(BirtDateTime.now()) - 1
  • Hi Eric,

    So do I need to create two separate parameters to use the above functions for getting the Current and Previous Year? I already tried this function, but I can get only one value at a time in dropdown. I need only one parameter where I can show both these values.

    Thanks.
  • Yes, my suggestion uses two parameters. Why don't you just create another dataset and and return the values to a single parameter?
  • Thanks Eric. For now I just created a static List Box parameter with two values as - Current Year and Previous Year. Based on the parameter value I select, I need to filter the report results. For example, if I select 'Current Year', I need to show only those records which has Planned Start Date in this year. But I'm not able to filter that with below code.

    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 find the attached screenshot for the results I'm getting.
Sign In or Register to comment.