Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Filter by week,month,quarter and year
ajunuthula
Hi,
There is a column in the table as date. There is a parameter in the report called period as list box with values Week,Month,Quarter and Year. When a user selects week, then the records must be filtered by week,
and so on. i.e., filter must be done by weekly or monthly or qarterly or yearly.
Can anyone help us here.
Thank you.
Find more posts tagged with
Comments
johnw
you can use the BirtDateTime functions that are available in the expression editor to help.
so, in your table, you would write an expression like:
if (param["month"] != null)
{
param["month"];
}
if (param["day"] != null)
{
param["day"]
}
etc.
etc.
set the expression to equals
and for the value expression, use the following:
if (param["month"] != null)
{
BirtDateTime.month(row["myDate"]);
}
if (param["day"] != null)
{
BirtDateTime.month(param["day"]);
}
etc.
etc.
ajunuthula
Thank you.
But I have my parameter named as "period" and it has options as day,week,month,quarter and year.
So how the expression should be?
Thank you.
thuston
Have a hidden Date parameter (or two) for your date range in the query.<br />
<br />
In rptdesign initialize script, read the params["period"].value and set the date parameters.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>switch( params["period"].value )
{
// Date() has 0 based months
case 'Year':
params["StartDate"].value = new Date(BirtDateTime.year(BirtDateTime.today()),0,1,0,0,0,0)
params["EndDate"].value = BirtDateTime.addDay(new Date(BirtDateTime.year(BirtDateTime.today()),0,1,0,0,0,0),-1)
break;
case 'Month':
params["StartDate"].value = new Date(BirtDateTime.year(BirtDateTime.today()),BirtDateTime.month(BirtDateTime.today())-1,1,0,0,0,0)
params["EndDate"].value = BirtDateTime.addDay(new Date(BirtDateTime.year(BirtDateTime.today()),BirtDateTime.month(BirtDateTime.today()),1,0,0,0,0),-1)
break;
//...
default:
//code to be executed if value is different from case 1-n
}</pre>