Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
elinformal
Contributor
Contributor

Calcular diferencia con signos

Buenos días y gracias por anticipado.

 

Tengo 2 columnas con valores y quiero generar una 3 columna como resultado de la resta de la col(1) - col(2) y si directamente genero esa función, como quiero tener en cuenta los signos no puedo hacerlo, es decir, 

col(1) = +4.51

col(2)= -4.87

Resultado debería ser -0.36, no +9.38

 

Alguien me ayuda....

3 Replies
timpoismans
Specialist
Specialist

Using Google Translate to interpret your issue, so excuse any mistakes I make:

 

The 3rd column would just be:

Col(1) + Col(2)

In case Col(2) is positive, it would be just added to Col(1).
In case Col(2) is negative, it would add a negative number, which would be the same as Col(2) substracted from Col(1)

elinformal
Contributor
Contributor
Author

No puedo usar un col(1) + col(2) porque si los dos son positivos no me genera la diferencia.

 

 

timpoismans
Specialist
Specialist

Then try:

If(Col(2)<0,Col(1)+Col(2),Col(1)-Col(2))

If Col(2) is negative, it'll add the negative value to Col(1), if it's positive, it'll substract it from Col(1).