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 actual and next month
Bordihn
<p>Hi,</p>
<p> </p>
<p>I´m trying to filter my results within a report by the actual month + next month. Within my Data Set I´m using the operator Between (Static example: between "2015-12-01" and "2015-12-31"). I also tried (dynamic example: between "new Date()" and "new Date(getMonth() + 1)"), but the second value (add one month to the current one) is not working. I found no fitting solution for this, what am I missing?</p>
<p> </p>
<p>Thanks in advance and best regards.</p>
Find more posts tagged with
Comments
jfranken
<p>You could try the built in BIRT functions:</p>
<p> </p>
<p>Now:</p>
<p>BirtDateTime.now()</p>
<p> </p>
<p>One month from now:</p>
<p>BirtDateTime.addMonth(BirtDateTime.now(), 1)</p>
Bordihn
<p>Thanks jfranken,</p>
<p> </p>
<p>that worked pretty well.</p>
<p> </p>
<p>In a final step (cherry on the cake) I want now also to include my results from the last month, but just if they have a specific value.</p>
<p>Lets take oders as example. I want to show all orders with the due date of this month + the next month (that allready works), but also orders from the last month if they have the status "open" (thats the value, let`s say it can be only "open" and "closed"). In this way, orders which are still open appear in the report and don´t go by the board.</p>
<p> </p>
<p>Any ideas for that? Thanks in advance and best regards.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>Using the ORDERS table in ClassicModels, the following filter expression will return all orders between the parameter date and a month before where status is "Resolved" and all orders between the parameter date and a month in the future. I have also attached a report design. Hope this helps.</p>
<p> </p>
<div><span style="font-family:'courier new', courier, monospace;">(BirtComp.between(row["ORDERDATE"],BirtDateTime.addMonth(params["pDate"].value,-1),params["pDate"].value) && BirtComp.equalTo(row["STATUS"],"Resolved")) ||</span></div>
<div><span style="font-family:'courier new', courier, monospace;">BirtComp.between(row["ORDERDATE"],params["pDate"].value,BirtDateTime.addMonth(params["pDate"].value,1))</span></div>
<div> </div>
<div>P.</div>
Bordihn
<p>Hi pricher,</p>
<p> </p>
<p>your solution with the parameter worked pretty well, I just used instead the expression "BirtDateTime.firstDayOfMonth(BirtDateTime.today())" as default value for the Parameter and raised the value in the second row in the Data Set Filter to "BirtComp.between(row["defaultBaseplan.endDate"],params["pDate"].value,BirtDateTime.addMonth(params["pDate"].value,<span style="color:#ff0000;">2</span>))"</p>
<p> </p>
<p>This way the user gets always the actual month and the report works as expected.</p>
<p> </p>
<p>Thanks for your help and best regards.</p>
Bordihn
<p>Hi,</p>
<p> </p>
<p>I just recognized the fact that the posted filter expression filters not just the orders from last month with the status closed but rather also the orders from the actual month with the status closed - meaning, the filter is not limited to the last month.</p>
<p> </p>
<p>This is the actual dataSet Filter expression:</p>
<p>(BirtComp.between(row["ORDERDATE"],BirtDateTime.addMonth(params["pDate"].value,-2),params["pDate"].value) && BirtComp.equalTo(row["STATUS"],"Resolved")) ||<br>
BirtComp.between(row["ORDERDATE"],params["pDate"].value,BirtDateTime.addMonth(params["pDate"].value,2))</p>
<p> </p>
<p>As you can see we have now 4 months. When I generate the report for December, it shows the penultimate month (October), the last month (November), the actual month (December) and the next month (January).</p>
<p>The mentioned expression above now hides closed orders for October (as wished), but also hides closed orders for November (issue). December and January works as expected (no filtering by status).</p>
<p> </p>
<p>How can I avoid the "all or nothing" filter? All my trials with a data Set Filter or with the visibilty function failed, so that my expression filters all closed orders or all open orders or nothing (by status).</p>
<p> </p>
<p>Thanks again in advance and best regards.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>You can change the filter expression so that the logic for each month (penultimate, last, actual and next) is treated separately. The following expression will filter has 3 parts: <span style="color:#0000ff;">1)</span> Show only the "Shipped" orders for the penultimate month; <span style="color:#ee82ee;">2)</span> Show all orders for the last month; <span style="color:#ff8c00;">3)</span> Show all orders for the actual and next month. </p>
<p> </p>
<div><span style="font-family:'courier new', courier, monospace;"><span style="color:#0000ff;">(BirtComp.between(row["ORDERDATE"],BirtDateTime.addMonth(params["pDate"].value,-2),BirtDateTime.addMonth(params["pDate"].value,-1)) && BirtComp.equalTo(row["STATUS"],"Shipped"))</span> ||</span></div>
<div><span style="font-family:'courier new', courier, monospace;"><span style="color:#ee82ee;">(BirtComp.between(row["ORDERDATE"],BirtDateTime.addMonth(params["pDate"].value,-1),params["pDate"].value))</span> ||</span></div>
<div><span style="color:#ff8c00;"><span style="font-family:'courier new', courier, monospace;">BirtComp.between(row["ORDERDATE"],params["pDate"].value,BirtDateTime.addMonth(params["pDate"].value,2))</span></span></div>
<div> </div>
<div>Hope this helps,</div>
<div> </div>
<div>P.</div>
Bordihn
<p>Hi pricher,</p>
<p> </p>
<p>your filter expression solves the issue exactly, I will keep the seperation logic in mind.</p>
<p> </p>
<p>Thanks a lot and happy holidays
</p>
amrutaraut99@gmail.com
<p>Hi,</p>
<p>Could you please give me a suggestion on how to filter a data day wise?</p>
<p> </p>
<p>Thanks in advance</p>