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)
Year-by-Year comparism
marcs
<p>Hi guys,</p>
<p> </p>
<p>first of all: this forum is great. I'm new to Birt but learned alot here :-)</p>
<p>But one task I have at hand I cannot find a solution yet although I think it's not uncommon:</p>
<p> </p>
<p>I want to compare agregated sales numbers to the numbers of previous year.</p>
<p> </p>
<p>Example:</p>
<p>I have a db table with the following columns columns:</p>
<p>DateOfOrder | NumberOfSoldItems | Platform</p>
<p> </p>
<p>With that I made a crosstab so I can see the summarized NumberOfItems sold per Month and Platform.</p>
<p> </p>
<p>I now want to compare these NumberOfItems to the NumberOfItems of the same month of the last year and show the difference in the table cell.</p>
<p> </p>
<p>The user sets two report parameters: begindate and enddate</p>
<p> </p>
<p>Ii already tried to make 2 date sources with 2 their data sets: one giving the results of the sales within chosen begindate and enddate and another data set with the same parameters minus one year.</p>
<p> </p>
<p>Then I tried to combine these two datasets into one but I don't know at which level I can access the two NumberOfItems dates to compare/substract them.</p>
<p> </p>
<p>If someone could point me into the right direction it would be great, I'm trying and searching since days now...</p>
<p> </p>
<p>Thank you in advance!</p>
<p>Marc</p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>You should be able to do this by using Relative Time Periods in a cross tab. You can find the Relative Time Periods component in the palette. Drag one in the summary area of a cross tab and choose the appropriate Time Period. Each time period you add becomes a data binding that you can use later in a calculation.</p>
<p> </p>
<p>I am sending you an example based on Classic Models that shows in the crosstab the difference between current year and previous year for each country. Hopefully, this will help you build your solution.</p>
<p> </p>
<p>P.</p>
marcs
<p>Hi Mr. P. ;-)</p>
<p> </p>
<p>thanks a lot! This is exaclty what I needed. Some thingsin live are easy :-)</p>
<p> </p>
<p>best regards</p>
<p>Marc</p>
kumbare
<p>Hi pricher,</p>
<p> </p>
<p>Is there any expression to find difference between two years</p>
<p> </p>
<p>such as data["currentYear"]-data["previousYear"].</p>
<p> </p>
<p>Thanks in advance.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>Simply choose Previous N Year and Current Year in the Relative Time Period dialog, as shown here:</p>
<p> </p>
<p>
kumbare
<p>Hi Pricher,</p>
<p> </p>
<p>Thank you for quick response. I am new to BIRT.</p>
<p> </p>
<p>is it possible for you to implement same in your <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?app=core&module=attach§ion=attach&attach_id=10917'
title="Download attachment"><strong>YearOverYear.rptdesign</strong></a> ?</p>
<p> </p>
<p>Ref thread ( <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/36961-year-vs-year-1-comparison-in-birt-cross-tab/?p=137921'>http://developer.actuate.com/community/forum/index.php?/topic/36961-year-vs-year-1-comparison-in-birt-cross-tab/?p=137921</a>.</p>
;
<p> </p>
<p>Please help.</p>
<p> </p>
<p>Thanks in advance.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>Attached is an example that shows Year over Year difference. The YoY value is a computed value where PY is subtracted from Current Year. Also, because there cannot be a YoY for the first year of data, I have added a visibility rule to hide the field when Year = 2011.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
kumbare
<p>Hi Pricher,<br>
<br>
Thanks a lot for your help. It worked for me.<br>
<br>
I am facing another issue in same report. Please refer below screen shot.<br>
<br>
Diff is derived column in cross tab so i not able to calculate sub totals and grand totals of the Diff column.<br>
<br>
Please help me to calculate derived columns subtotal in cross tab.</p>
<p> </p>
<p>
</p>
<p> </p>
<p>Year 2011 YoY 2012 YoY Diff<br>
COUNTRY States <br>
Australia </p>
<p> a1 2514 100 2414<br>
a2 872 200 672<br>
a3 47 300 -253<br>
a4 500 400 100<br>
a5 903 500 403<br>
Sub totals 4836 1500 <strong><span style="color:#ff0000;">3336</span></strong><br>
Belgium </p>
<p> b1 5400 100 5300<br>
b2 1200 200 1000<br>
b3 1300 300 1000<br>
b4 100 400 -300<br>
b5 5600 500 5100<br>
Sub totals 13600 1500 <strong><span style="color:#ff0000;">12100</span></strong><br>
Total 18436 3000 <span style="color:#ff0000;"><strong>15436</strong></span></p>
<p> </p>
<p>
</p>
pricher
<p>Hi,</p>
<p> </p>
<p>You have to calculate the sub and grand totals individually for relative time periods and derived measures. Take a look at the attached example.</p>
<p> </p>
<p> </p>
<p>P.</p>
kumbare
<p>Thank you Pierre.</p>
<p> </p>
<p>Could you please elaborate this solution ?</p>
<p> </p>
<p>Have you written any script for calculation ?</p>
pricher
<p>Here are the general steps:</p>
<p> </p>
<p>1. Start with a basic Data Cube like this one:</p>
<p>
kumbare
<p>Thanks a lot Pierre for detailed explanation.</p>
<p> </p>
<p>I will apply it in my cross tab report.</p>
kumbare
<p>Hi Pierre,</p>
<p> </p>
<p>Is there any way to hide cross tab columns say year difference column ?</p>
<p> </p>
<p>How to hide a particular column in cross tab ?</p>
pricher
<p>Best way is to use the Visibility attribute on the element(s) you want to hide. For example, to hide the YoY values for 2011, check the Hide Element property in the Visibility attribute and apply the condition data["Year"] == 2011, as shown below:</p>
<p>
kumbare
<p>Hi Pierre,</p>
<p> </p>
<p>Thank you for this solution.</p>
<p> </p>
<p>I am not using grid in cross tab so it is hiding element but not the blank column. it is showing blank column</p>
<p> </p>
<p>Is there any other way which can always hide 4th number of column in cross tab irrespective of the value in column ?</p>
<p> </p>
<p>Can we write any script for this ?</p>
pricher
<p>Hi,</p>
<p> </p>
<p>Sorry for the late reply... Can you share an example or a screen shot of what you are trying to accomplish?</p>
<p> </p>
<p>Thanks,</p>
<p> </p>
<p>P.</p>
kumbare
<p>Hi,</p>
<p> </p>
<p>We can take any cross tab example <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?app=core&module=attach§ion=attach&attach_id=11980'
title="Download attachment"><u>lets take example of </u><strong>YearOverYear4.rptdesign</strong></a> shared earlier by you.</p>
<p> </p>
<p>I want to hide column D in excel irrespective of its value.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>Instead of applying the Visibility attribute to the element, you can apply it to the whole grid column. The attached sample design does that and when you export to Excel, the whole column disappears.</p>
<p> </p>
<p>P.</p>
kumbare
<p>Hi ,</p>
<p> </p>
<p>I am using Relative time period in Cross tabs to compare sales report with next year.</p>
<p> </p>
<p>When I run it in eclipse (Run-View Report -as xlsx) It is calculating decrease in revenue properly but when am running it through java application, formula applied on these relative time periods are not getting properly calculated.</p>
<p> </p>
<p>I am creating one war for BIrt report and we are creating dynamic url to hit that war file from java application.</p>
<p> </p>
<p>Is there anything that i need provide in to URL?</p>
<p> </p>
<p>Please help.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>That would be out of my scope. Maybe someone else can chime in.</p>
<p> </p>
<p>P.</p>
kumbare
<p>Hi Pierre,</p>
<p> </p>
<p>Thank you for quick reply.</p>
<p> </p>
<p>Can you please confirm that "Relative time period" is also available in lower versions of BIRT i.e. <4x ?</p>
pricher
<p>Relative Time Periods were introduced in <a data-ipb='nomediaparse' href='
https://eclipse.org/birt/phoenix/project/notable4.2.php'>BIRT4.2</a></p>
;
kumbare
<p>Hi Pierre,<br>
<br>
Thank you Pierre.<br>
<br>
Everything looks good after changing BIRT version.<br>
<br>
I want to change sequence of the comparison columns and move these columns at the end of year column. in current design we are showing these column next to each year.<br>
<br>
is it possible to show all the comparison columns at the end of the year column using cross tab design ?<br>
<br>
Please help.</p>
pricher
<p>Not really doable.</p>
<p> </p>
<p>In a crosstab, the relative time period fields are generated dynamically and their number will vary depending on the number of columns generated by the dimension going across, in your case Year. Hence, you cannot have them all at once at the end of each row. If your requirements are similar to the screenshot you posted, i.e. show the data for 3 years only, a better solution might be to use a regular table and compute your relative time periods by creating aggregates for each year by city and then create bindings that calculate the difference between the years. I have attached a sample of what it might look like.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
kumbare
<p>Hi Pierre,</p>
<p> </p>
<p>Thank you for your help.</p>
<p> </p>
<p>I want to migrate from BIRT 2.6 to 4.2. I have war created for older version.</p>
<p> </p>
<p>Could you please help me to migrate this war file to 4.2 ?</p>
<p> </p>
<p>What are the required changes to migrate this war file to 4.2 ?</p>
pricher
<p>Hi,</p>
<p> </p>
<p>I am not an expert on this. I would strongly suggest you start a new thread on the <em>Integrating with BIRT Runtime</em> forum to get help.</p>
<p> </p>
<p>Regards,</p>
<p> </p>
<p>P.</p>
kumbare
<p>Hi,</p>
<p> </p>
<p>Thank you for your help.</p>
<p> </p>
<p>There is something wrong with relative time period function. I am getting below year if I am setting Next yer relative period Reference to Today.</p>
<p> </p>
<p>I guess due to this reference field only 'relative time period function' for Next year calculation is not working in my application.</p>
<p> </p>
<p> </p>
<p>Caused by: java.lang.ArrayIndexOutOfBoundsException<br>
at java.lang.System.arraycopy(Native Method)<br>
at org.eclipse.birt.data.engine.olap.data.impl.aggregation.TimeFunctionCalculator.getAggregationResultSet(TimeFunctionCalculator.java:523)<br>
at org.eclipse.birt.data.engine.olap.data.impl.aggregation.AggregationExecutor.execute(AggregationExecutor.java:337)<br>
at org.eclipse.birt.data.engine.olap.data.api.CubeQueryExecutorHelper.onePassExecute(CubeQueryExecutorHelper.java:944)<br>
at org.eclipse.birt.data.engine.olap.data.api.CubeQueryExecutorHelper.executeFactTableQuery(CubeQueryExecutorHelper.java:484)<br>
at org.eclipse.birt.data.engine.olap.data.api.CubeQueryExecutorHelper.execute(CubeQueryExecutorHelper.java:417)<br>
at org.eclipse.birt.data.engine.olap.query.view.QueryExecutor.executeQuery(QueryExecutor.java:951)<br>
at org.eclipse.birt.data.engine.olap.query.view.QueryExecutor.populateRs(QueryExecutor.java:904)<br>
at org.eclipse.birt.data.engine.olap.query.view.QueryExecutor.execute(QueryExecutor.java:183)<br>
at org.eclipse.birt.data.engine.olap.query.view.BirtCubeView.createCubeCursor(BirtCubeView.java:201)<br>
at org.eclipse.birt.data.engine.olap.query.view.BirtCubeView.getCubeCursor(BirtCubeView.java:182)<br>
at org.eclipse.birt.data.engine.olap.impl.query.CubeQueryResults.createCursor(CubeQueryResults.java:298)<br>
at org.eclipse.birt.data.engine.olap.impl.query.CubeQueryResults.getCubeCursor(CubeQueryResults.java:161)<br>
at org.eclipse.birt.report.engine.data.dte.CubeResultSet.<init>(CubeResultSet.java:78)<br>
at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteCube(DteDataEngine.java:249)<br>
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:280)<br>
at org.eclipse.birt.report.engine.executor.ExecutorManager$ExecutorContext.executeQuery(ExecutorManager.java:447)<br>
at org.eclipse.birt.report.item.crosstab.core.re.executor.BaseCrosstabExecutor.executeQuery(BaseCrosstabExecutor.java:122)<br>
at org.eclipse.birt.report.item.crosstab.core.re.executor.CrosstabReportItemExecutor.execute(CrosstabReportItemExecutor.java:102)<br>
at org.eclipse.birt.report.engine.executor.ExtendedItemExecutor.execute(ExtendedItemExecutor.java:62)<br>
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)<br>
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)<br>
at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)<br>
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)<br>
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)<br>
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)<br>
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:181)</p>
pricher
<p>Hi,</p>
<p> </p>
<p>Can you send your report?</p>
<p> </p>
<p>P.</p>
kumbare
<p>Hi Pierre,</p>
<p> </p>
<p>Sorry but it is very big report and will require DS.</p>
<p> </p>
<p>I am getting this error when i am using Next N year feature of the 'Relative Time Period' but if i change it to Previous N Year it is working fine.</p>
<p> </p>
<p>Problem with using Previous N Year is that i am not able to hide empty columns in cross tab for first year. I can not use grid as it dues not look good.</p>
<p> </p>
<p>Could you please help me to completely remove cells from excel sheet using script ?</p>
<p> </p>
<p>Or if i will be using Grid in Cross Tab then will these grid cell will appear separate cells in excel ?</p>
<p> </p>
<p> </p>
<p>Please help me.</p>
pricher
<p>As I explained earlier in this thread, crosstabs can be a bit hard to work with as they tend to be a bit rigid. Sometimes, based on the requirements, it is easier to use a table, as I have shown in YearOverYear5.rptdesign sent earlier.</p>
<p> </p>
<p>Without your report design, it will be very hard to come up with a solution. Plus I don't understand how using Next N period as a relative period will give you the correct results since Year over Year typically compares this year with the previous year, not the next.</p>
<p> </p>
<p>P.</p>