Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Suma con función Fabs desde Script

Buenos Días,

Tengo la siguiente tabla residente:

ClaveColumna1Columna2
JHabr2013-37556,0132097,15
JHago2013-28714,9833537,34
JHdic+2013-23793,06-1065,53
JHdic2013-49990,4133133,13
JHene2013-57532,1433679,99
JHfeb2013-36602,7333634,57
JHjul2013-34940,2832792,56
JHjun2013-33227,2732562,92
JHmar2013-7065,0132693,15
JHmay2013-32576,3231875,36
JHnov2013-31461,7834579,34
JHoct2013-35936,2432662,81
JHsep2013-32237,9532566,89
-441634,18394749,68

Quiero obtener, desde Script, un nuevo campo, que multiplique la suma de las dos columnas, pero en valor absoluto.

Es decir 441.634,18 * 394.749,68 = 174.334.951.232,0624

Necesito calcular la suma de las columnas, teniendo en cuenta los negativos, pero a la hora de multiplicar los valores resultantes de esas sumas, que lo haga sobre valor absoluto.

Si hago fabs(sum(Columna1) * fabs(sum(Columna2), pierdo los negativos y el total no es el correcto.

Alguien me puede orientar?

Gracias!

8 Replies
Highlighted

Re: Suma con función Fabs desde Script

In the script you can do:

Load

...

Fabs(Columna1 * Columna2) as newCol

...

In the table you can do (in an expression):

Fabs(Sum(Columna1 * Columna2))

Let me know

Highlighted
Not applicable

Re: Suma con función Fabs desde Script

Hi Alesandro,

Thanks for your answer...

In that case, the sum of new column is 13.827.668.351 and the result that I need is:

Sum Column1 * Sum Column2

441.634,18 * 394.749,68 = 174.334.951.232,0624

ClaveColumna1Columna2NewColumn
JHabr2013-37556,0132097,151205440886
JHago2013-28714,9833537,34963024047,4
JHdic+2013-23793,06-1065,5325352219,22
JHdic2013-49990,4133133,131656338753
JHene2013-57532,1433679,991937681900
JHfeb2013-36602,7333634,571231117084
JHjul2013-34940,2832792,561145781228
JHjun2013-33227,2732562,921081976935
JHmar2013-7065,0132693,15230977431,7
JHmay2013-32576,3231875,361038381927
JHnov2013-31461,7834579,341087927588
JHoct2013-35936,2432662,811173778579
JHsep2013-32237,9532566,891049889771
Highlighted

Re: Suma con función Fabs desde Script

Could you please verify this expression?

Sum(TOTAL fabs(Columna1)) * Sum(TOTAL fabs(Columna2))

Highlighted
Not applicable

Re: Suma con función Fabs desde Script

With this expression, in set analisys, the results is near that I need, but not exactly...

But this expression is not allowed in Script Code.

Probably i'm wrong in my approach.

Highlighted

Re: Suma con función Fabs desde Script

This expression must be used in the UI object, not in the script ...

Highlighted

Re: Suma con función Fabs desde Script

this is what you need as your expression ...

Fabs(Sum(TOTAL Columna1) * Sum(TOTAL Columna2))

Highlighted
Not applicable

Re: Suma con función Fabs desde Script

Hi Alessandro,

Exactly, this expression, return the value, but muy objective, was obtain it in the script.

I will continue to try.

Thanks for your time.

Highlighted

Re: Suma con función Fabs desde Script

Here it is the script:

Orig:

LOAD * Inline [

Clave, Columna1, Columna2

JHabr2013, '-37556,01', '32097,15'

JHago2013, '-28714,98', '33537,34'

JHdic2013, '-23793,06', '-1065,53'

JHdic2013, '-49990,41', '33133,13'

JHene2013, '-57532,14', '33679,99'

JHfeb2013, '-36602,73', '33634,57'

JHjul2013, '-34940,28', '32792,56'

JHjun2013, '-33227,27', '32562,92'

JHmar2013, '-7065,01', '32693,15'

JHmay2013, '-32576,32', '31875,36'

JHnov2013, '-31461,78', '34579,34'

JHoct2013, '-35936,24', '32662,81'

JHsep2013, '-32237,95', '32566,89'

];

NewTab:

NoConcatenate

LOAD Fabs(Sum(Columna1) * Sum(Columna2)) as totale Resident Orig;