Problem With Calculated Field [message #174035] |
Thu, 25 May 2006 12:34 |
serafo
Messages: 24 Registered: May 2006
|
Junior Member |
|
|
Good Morning.
I am trying to build the report show in the file I Sent. I will try to explain , my english is poor.
The column "Ejecucion Anterior" is a calculated field using the LAG function as Follows :
LAG(Saldocapital AVG,1) OVER(PARTITION BY Producto.Grupo Productos,Producto.Producto,Responsable.Filial,Responsable.Zona,Responsable.Ciudad,Responsable.Responsable ORDER BY Tiempo.Fecha ASC , Tiempo.Numero Mes ASC , Tiempo.Trimestre ASC )
It works fine. For example, for the row "Cuenta Corriente" , the "Ejecucion Anterior" value is the value for the "Trimestre 1". The user is searching for information in "Trimestre 2".
The "Variacion $" column is a calculated field as follows:
"Ejecucion Actual" - "Ejecucion Anterior". It works fine too.
The "Variacion %" column must be a calculated field as follows:
("Ejecucion Actual" - "Ejecucion Anterior") / "Ejecucion Anterior"
or
"Variacion $" / "Ejecucion Anterior"
When I tried to build this formula, I always got the error :
ORA-01476 : Divisor is equal to zero.
The values of column "Variacion %" shown in the figure are calculated as follows :
"Variacion $" / "Presupuesto AVG"
and there is no error.
The column "Presupuesto AVG" is not a Calculated Field, is the only difference.
Could you help me please..!
|
|
|
Re: Problem With Calculated Field [message #174497 is a reply to message #174035] |
Mon, 29 May 2006 07:15 |
skooman
Messages: 913 Registered: March 2005 Location: Netherlands
|
Senior Member |
|
|
Hi Serafo,
You could try to avoid the error by making sure that the "down" part of the division can never be null or zero. You can do this using a decode or a case when else:
decode("Ejecucion Anterior",null,0,"Ejecucion Actual" - "Ejecucion Anterior") / "Ejecucion Anterior")
Regards,
Sabine
|
|
|
Re: Problem With Calculated Field [message #175883 is a reply to message #174497] |
Mon, 05 June 2006 18:47 |
serafo
Messages: 24 Registered: May 2006
|
Junior Member |
|
|
Thanks a lot Sabine.
It works fine. Now I have a question, I hope you can help me as always.
The data that I am presenting is too big, i.e 9158245963.36
I was trying to format this in order to show the values in millions, ie 158245963.36 -->9.158.
I haven't been able to do it, please help me.
Best Regards,
Ser@fo
|
|
|
|
|
|