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)
how to compare a month by html button
404040
hi...
my question is how to compare a this month and last month and then this year and last year ....
in html button
first of all how to get date field for this month and last month and then how can i able compare
by click of html button
can u able to create sampledb for this..
kindly help me...
thank in advance
Find more posts tagged with
Comments
kclark
I've attached an example of how you could do this. I used hyperlinks in my examples but have include html buttons that will work also if you plug in your report url.<br />
<br />
First I created a listbox parameter allowing the user to choose month or year. Then in the beforeOpen() of the data set I check the parameter value and change the query with this code.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if(params["compareParam"].value == 2) {
this.queryText = "select * from payments where paymentdate between '2003-01-01' and '2004-12-31'";
}else{
this.queryText = "select * from payments where paymentdate between '2004-06-01' and '2004-07-31'";
}</pre>
<br />
Then I created two charts and placed them in a grid. This way I can check the parameter value and drop the one I don't need. If there is no value to the parameter then both grids are dropped.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>YearGrid = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("year");
MonthGrid = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("month");
if(params["compareParam"].value == 2) {
MonthGrid.drop();
}else if(params["compareParam"].value == 1) {
YearGrid.drop();
}else{
YearGrid.drop();
MonthGrid.drop();
}</pre>
<br />
Then I used two hyperlinks to pass back to the report which report needs to be dropped. If you're wanting to use buttons then you would use some code like this in a text object..<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<html>
<head>
<script>
function year() {
window.location = "http://localhost:8080/viewer/frameset?__report=myreport.rptdesign&parm1=1" // url to your report
}
function month() {
window.location = "http://localhost:8080/viewer/frameset?__report=myreport.rptdesign&parm1=2" // url to your report
}
</script>
</head>
<body>
<button type="button" onClick="year();">This year vs last</button> or <button type="button" onClick="month();">This month vs last</button>
</body>
</html></pre>
<br />
Let me know if you have any questions!
404040
thank u very much ..............clark