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)
DataSet Computed columns Issue
Suneel Mac
Hi..<br />
<br />
I am creating computed columns in dataset1 for displaying data specified format..<br />
<br />
In one x.rptdesignfile i am created 1 computed column (row["AMOUNTT"], string type) like below..<br />
<br />
Expression:-<br />
<br />
if (row["AMOUNT"]< 0){<br />
"($" + Formatter.format(row["AMOUNT"],"###,##0") + ")";<br />
}<br />
else if (row["AMOUNT"] > 0){<br />
"$" + Formatter.format(row["AMOUNT"],"###,##0");<br />
}else<br />
{<br />
"-";<br />
}<br />
<br />
Bcoz I want to display output like<br />
<br />
if amount is < 0 Ex:: 23456 -- i want to display like ($23,456)<br />
<br />
if amount is > 0 Ex:: 23456 -- i want todisplay like $23,456<br />
<br />
if amount is =0 Ex:: 0 -- i want to display like -<br />
<br />
But is is throwing some exception while previewing the results.. like..<br />
<br />
<br />
org.eclipse.birt.data.engine.core.DataException: Fail to compute value for computed column "row["FEE"]".<br />
A BIRT exception occurred. See next exception for more information.<br />
There are errors evaluating script "if (row["FEE"] > 0){<br />
<br />
"($" + Formatter.format(row["AMOUNT"],"###,##0") + ")";<br />
<br />
}<br />
<br />
else if (row["AMOUNT"] < 0){<br />
<br />
"$" + Formatter.format(row["AMOUNT"],"###,##0");<br />
<br />
}else<br />
<br />
{<br />
<br />
"-";<br />
<br />
}":<br />
Invalid field name: AMOUNT.<br />
<br />
at org.eclipse.birt.data.engine.impl.ComputedColumnHelperInstance.process(ComputedColumnHelper.java:511)<br />
<br />
at org.eclipse.birt.data.engine.impl.ComputedColumnHelper.process(ComputedColumnHelper.java:119)<br />
<br />
at org.eclipse.birt.data.engine.executor.cache.RowResultSet.processFetchEvent(RowResultSet.java:152)<br />
<br />
at org.eclipse.birt.data.engine.executor.cache.RowResultSet.next(RowResultSet.java:113)<br />
<br />
at org.eclipse.birt.data.engine.executor.transform.SimpleResultSet.<init>(SimpleResultSet.java:90)<br />
<br />
at org.eclipse.birt.data.engine.executor.DataSourceQuery.execute(DataSourceQuery.java:996)<br />
<br />
at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery$OdaDSQueryExecutor.executeOdiQuery(PreparedOdaDSQuery.java:441)<br />
<br />
at org.eclipse.birt.data.engine.impl.QueryExecutor.execute(QueryExecutor.java:1103)<br />
<br />
at org.eclipse.birt.data.engine.impl.ServiceForQueryResults.executeQuery(ServiceForQueryResults.java:232)<br />
<br />
at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:173)<br />
<br />
at org.eclipse.birt.report.engine.api.impl.ExtractionResults.nextResultIterator(ExtractionResults.java:74)<br />
<br />
at org.eclipse.birt.report.designer.data.ui.dataset.DataSetPreviewer.preview(DataSetPreviewer.java:59)<br />
<br />
at org.eclipse.birt.report.designer.data.ui.dataset.ResultSetPreviewPage$5.run(ResultSetPreviewPage.java:336)<br />
<br />
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)<br />
<br />
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)<br />
<br />
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)<br />
<br />
at org.eclipse.birt.report.designer.data.ui.dataset.ResultSetPreviewPage.updateResultsProcess(ResultSetPreviewPage.java:376)<br />
<br />
at org.eclipse.birt.report.designer.data.ui.dataset.ResultSetPreviewPage.access$1(ResultSetPreviewPage.java:300)<br />
<br />
at org.eclipse.birt.report.designer.data.ui.dataset.ResultSetPreviewPage$4.runInUIThread(ResultSetPreviewPage.java:249)<br />
<br />
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)<br />
<br />
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)<br />
<br />
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)<br />
<br />
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)<br />
<br />
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)<br />
<br />
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)<br />
<br />
at org.eclipse.jface.window.Window.open(Window.java:801)<br />
<br />
at org.eclipse.birt.report.designer.ui.dialogs.BaseDialog.open(BaseDialog.java:111)<br />
<br />
at org.eclipse.birt.report.designer.data.ui.providers.EditableDataSetNodeProvider.performEdit(EditableDataSetNodeProvider.java:102)<br />
<br />
at org.eclipse.birt.report.designer.internal.ui.views.DefaultNodeProvider.performRequest(DefaultNodeProvider.java:442)<br />
<br />
at org.eclipse.birt.report.designer.internal.ui.views.actions.EditAction.doAction(EditAction.java:90)<br />
<br />
at org.eclipse.birt.report.designer.internal.ui.views.actions.AbstractElementAction.run(AbstractElementAction.java:70)<br />
<br />
at org.eclipse.birt.report.designer.internal.ui.views.RenameListener.doubleClick(RenameListener.java:214)<br />
<br />
at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:824)<br />
<br />
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)<br />
<br />
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)<br />
<br />
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)<br />
<br />
at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:822)<br />
<br />
at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1421)<br />
<br />
at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1225)<br />
<br />
at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:238)<br />
<br />
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:235)<br />
<br />
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:296)<br />
<br />
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)<br />
<br />
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)<br />
<br />
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)<br />
<br />
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)<br />
<br />
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)<br />
<br />
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)<br />
<br />
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)<br />
<br />
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)<br />
<br />
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)<br />
<br />
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)<br />
<br />
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)<br />
<br />
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)<br />
<br />
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)<br />
<br />
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)<br />
<br />
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)<br />
<br />
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)<br />
<br />
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)<br />
<br />
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
<br />
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)<br />
<br />
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)<br />
<br />
at java.lang.reflect.Method.invoke(Unknown Source)<br />
<br />
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)<br />
<br />
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)<br />
<br />
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)<br />
<br />
Caused by: org.eclipse.birt.data.engine.core.DataException: A BIRT exception occurred. See next exception for more information.<br />
There are errors evaluating script "if (row["AMOUNT"] > 0){<br />
<br />
"($" + Formatter.format(row["AMOUNT"],"###,##0") + ")";<br />
<br />
}<br />
<br />
else if (row["AMOUNT"] < 0){<br />
<br />
"$" + Formatter.format(row["AMOUNT"],"###,##0");<br />
<br />
}else<br />
<br />
{<br />
<br />
"-";<br />
<br />
}":<br />
Invalid field name: AMOUNT.<br />
<br />
at org.eclipse.birt.data.engine.core.DataException.wrap(DataException.java:118)<br />
<br />
at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evalExpr(ScriptEvalUtil.java:955)<br />
<br />
at org.eclipse.birt.data.engine.impl.ComputedColumnHelperInstance.process(ComputedColumnHelper.java:474)<br />
<br />
... 65 more<br />
<br />
Caused by: org.eclipse.birt.core.exception.CoreException: There are errors evaluating script "if (row["AMOUNT"] > 0){<br />
<br />
"($" + Formatter.format(row["AMOUNT"],"###,##0") + ")";<br />
<br />
}<br />
<br />
else if (row["AMOUNT"] < 0){<br />
<br />
"$" + Formatter.format(row["AMOUNT"],"###,##0");<br />
<br />
}else<br />
<br />
{<br />
<br />
<br />
<em class='bbc'><strong class='bbc'>CAN YOU HELP ME ON THIS ISSUE..?</strong></em><br />
<br />
<br />
Thanks & regards<br />
<br />
SuneelKumar
Find more posts tagged with
Comments
Hans_vd
Hi SuneelKumar,<br />
<br />
Are you saying that you are creating a computed column row["AMOUNT"] and in the expression to determine it's value you write <pre class='_prettyXprint _lang-auto _linenums:0'>if (row["AMOUNT"] >0) .... ?</pre>
You cannot refer to the value of a column while you are still building that same value.<br />
<br />
Regards<br />
Hans
Suneel Mac
Thankyou for reply...
For displaying the particular output i want to create new Computed column in the same dataset ,
Bcoz, Depending upon the amount value i want display the output in specified format
Example :- In abc dataset i have 3 columns row["NAME"],row["NUMBER"], row["AMOUNT"]...
But ,I want to display output like
if amount is < 0 Ex:: amount value is 23456 -- i want to display like ($23,456)
if amount is > 0 Ex:: amount value is 23456 -- i want to display like $23,456
if amount is = 0 Ex:: amount value is 0 -- i want to display like -
i created computed column row["AMOUNT1"] as String type and i placed the following Expression in that
f (row["AMOUNT"]< 0){
"($" + Formatter.format(row["AMOUNT"],"###,##0") + ")";
}
else if (row["AMOUNT"] > 0){
"$" + Formatter.format(row["AMOUNT"],"###,##0");
}else
{
"-";
}
Thanks & regards
SuneelKumar