Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
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!

9 Replies
alexandros17
Partner - Champion III
Partner - Champion III

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

Not applicable
Author

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
alexandros17
Partner - Champion III
Partner - Champion III

Could you please verify this expression?

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

Not applicable
Author

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.

alexandros17
Partner - Champion III
Partner - Champion III

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

alexandros17
Partner - Champion III
Partner - Champion III

this is what you need as your expression ...

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

Not applicable
Author

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.

alexandros17
Partner - Champion III
Partner - Champion III

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;

Rosario_Aguilar
Partner - Contributor II
Partner - Contributor II

Hi Alexandros,

I try to do this last way, but this not worked. I need to do calculate EBITDA, and I used this way, because i need this solution type in the scripts, but i can't . Can you tell me if you have another solution?

Rosario_Aguilar_0-1599159400894.png