COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: erjorgea on 29 Oct 2018 08:07:45 AM

Title: Controle value /0
Post by: erjorgea on 29 Oct 2018 08:07:45 AM
Hi

I have an expression that rest the value of one year to another year:

if(([ANYO_SELECCIONADO] is null) or ([ANYO_SELECCIONADO]=0))
THEN ([ANYO_ANTERIOR])
else if (([ANYO_ANTERIOR] is null) or ([ANYO_ANTERIOR]=0))
then ([ANYO_SELECCIONADO])
else ([ANYO_SELECCIONADO]-[ANYO_ANTERIOR]) / abs([ANYO_SELECCIONADO])


The problem is that when one of the years has no value or 0, but the other year has a valid value, the expression return me the value /0.


I want to control this value.

Thhx
Title: Re: Controle value /0
Post by: BigChris on 29 Oct 2018 08:51:34 AM
Might be easier with a case statement:


case
  when [ANYO_SELECCIONADO] is missing then [ANYO_ANTERIOR]
  when [ANYO_SELECCIONADO] = 0 then [ANYO_ANTERIOR]
  when [ANYO_ANTERIOR] is missing then [ANYO_SELECCIONADO]
  when [ANYO_ANTERIOR] = 0 then [ANYO_SELECCIONADO]
  Else ([ANYO_SELECCIONADO]-[ANYO_ANTERIOR]) / abs([ANYO_SELECCIONADO])
END
Title: Re: Controle value /0
Post by: erjorgea on 30 Oct 2018 04:44:29 AM
Great, now works properly, thx for the support