Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
pgalvezt
Specialist
Specialist

subtract with if sentence

Hello!

Im trying to subtract 2 results 6809552 - 3358651 = 3.450.901.

If(Departamento='Otros Ingresos Fuera De La Explotación',

Sum(Aggr(

If(Cuenta='32020410' and Subcuenta ='' and Cc='2000',Sum({<Año={'2015'},Departamento={'Otros Egresos Fuera De La Explotación'}>}MONTO*-1)

,Sum({<Año={'2015'}>}MONTO*-1)),Departamento,Cuenta,Subcuenta,Cc)))    This Gives 6.809.552

If(Departamento='Otros Egresos Fuera De La Explotación',

Sum(Aggr(

If(Cuenta='32020406' and Subcuenta ='' and Cc='2000',Sum({<Año={'2015'}>}MONTO*-1)-

If(Cuenta='32020411' and Cc='2000',Sum({<Año={'2015'},Departamento={'Otros Egresos Fuera De La Explotación'}>}MONTO*-1))

,Sum({<Año={'2015'}>}MONTO*-1)),Departamento,Cuenta,Subcuenta,Cc)))     This Gives -3.358651

What I want is to obtain 3.450.901 and put it into "Otros Ingresos Fuera de la Explotación" Department.


Thanks!

1 Solution

Accepted Solutions
sunny_talwar

Try this expression:

=If(Departamento = 'Otros Ingresos Fuera De La Explotación', Sum(TOTAL Aggr(RangeSum(If(Departamento='Otros Ingresos Fuera De La Explotación',

Sum(Aggr(

If(Cuenta='32020410' and Subcuenta ='' and Cc='2000',Sum({<Año={'2015'},Departamento={'Otros Egresos Fuera De La Explotación'}>}MONTO*-1)

,Sum({<Año={'2015'}>}MONTO*-1)),Departamento,Cuenta,Subcuenta,Cc))),

If(Departamento='Otros Egresos Fuera De La Explotación',

Sum(Aggr(

If(Cuenta='32020406' and Subcuenta ='' and Cc='2000',Sum({<Año={'2015'}>}MONTO*-1)-

If(Cuenta='32020411' and Cc='2000',Sum({<Año={'2015'},Departamento={'Otros Egresos Fuera De La Explotación'}>}MONTO*-1))

,Sum({<Año={'2015'}>}MONTO*-1)),Departamento,Cuenta,Subcuenta,Cc)))), Departamento)))



PFA also.

Best,

Sunny

View solution in original post

5 Replies
sunny_talwar

Try this expression:

=If(Departamento = 'Otros Ingresos Fuera De La Explotación', Sum(TOTAL Aggr(RangeSum(If(Departamento='Otros Ingresos Fuera De La Explotación',

Sum(Aggr(

If(Cuenta='32020410' and Subcuenta ='' and Cc='2000',Sum({<Año={'2015'},Departamento={'Otros Egresos Fuera De La Explotación'}>}MONTO*-1)

,Sum({<Año={'2015'}>}MONTO*-1)),Departamento,Cuenta,Subcuenta,Cc))),

If(Departamento='Otros Egresos Fuera De La Explotación',

Sum(Aggr(

If(Cuenta='32020406' and Subcuenta ='' and Cc='2000',Sum({<Año={'2015'}>}MONTO*-1)-

If(Cuenta='32020411' and Cc='2000',Sum({<Año={'2015'},Departamento={'Otros Egresos Fuera De La Explotación'}>}MONTO*-1))

,Sum({<Año={'2015'}>}MONTO*-1)),Departamento,Cuenta,Subcuenta,Cc)))), Departamento)))



PFA also.

Best,

Sunny

pgalvezt
Specialist
Specialist
Author

Thank you sunindia,

Question,

I need to add other account combinations.

example: Cuenta='32010302' and Subcuenta ='FW03' and Cc='2000'  But "Operaciones" Department takes the value for March. I dont want that, I need it in "Ingresos Fuera De La Explotación" Department.

Below is my formula.

This Works fine:

If(Departamento='Operaciones',

Sum(Aggr(

If(Cuenta='31020303' and Subcuenta='' and Cc='4407',Sum({<Año={'2015'}>}MONTO*-1) -

If(Cuenta='31020303' and Subcuenta='' and Cc='4407',Sum({<Año={'2015'}>}MONTO*-1))*0.7513,

Sum({<Año={'2015'}>}MONTO*-1)),Departamento,Cuenta,Subcuenta,Cc)),

If(Departamento='Casa Matriz',

Sum(Aggr(

If(Cuenta='31020906' and Subcuenta='GG29' and Cc='5990',Sum({<Año={'2015'}>}MONTO*-1)-

If(Cuenta='31020906' and Subcuenta='GG21' and Cc='5990',Sum({<Año={'2015'}>}MONTO*-1))

,Sum({<Año={'2015'}>}MONTO*-1)),Departamento,Cuenta,Subcuenta,Cc)),

If(Departamento = 'Otros Ingresos Fuera De La Explotación', Sum(TOTAL Aggr(RangeSum(If(Departamento='Otros Ingresos Fuera De La Explotación',

Sum(Aggr(

If(Cuenta='32020410' and Subcuenta ='' and Cc='2000',Sum({<Año={'2015'},Departamento={'Otros Egresos Fuera De La Explotación'}>}MONTO*-1)

,Sum({<Año={'2015'}>}MONTO*-1)),Departamento,Cuenta,Subcuenta,Cc))),

If(Departamento='Otros Egresos Fuera De La Explotación',

Sum(Aggr(

If(Cuenta='32020406' and Subcuenta ='' and Cc='2000',Sum({<Año={'2015'}>}MONTO*-1)-

If(Cuenta='32020411' and Cc='2000',Sum({<Año={'2015'},Departamento={'Otros Egresos Fuera De La Explotación'}>}MONTO*-1))

,Sum({<Año={'2015'}>}MONTO*-1)),Departamento,Cuenta,Subcuenta,Cc)))), Departamento))


,Sum({<Año={'2015'}>}MONTO*-1))))

pgalvezt
Specialist
Specialist
Author

Hi, sunindia, I hope you can help me with this...

In your answer (Test 17) why when I do clic in "Ingresos Fuera De La Explotación" Department All Accounts shows the same result? QlikView show only the result fine when there are not selections. But when I do clic, all accounts shows 3.450.901.


Thanks!

sunny_talwar

Can you share screenshot of with and without selection to point out the issue?

Best,

Sunny

pgalvezt
Specialist
Specialist
Author

If you add Cuenta, Subcuenta,and cc dimensions, all data show the same result. The idea is to show data for each account as show Sum({<Año={'2015'}>}MONTO*-1) this form show all data.

Look:

Total of "Otros Ingresos Fuera De La Explotación" Department total is 6.809.552

I have to substract the next accounts this is in ("Otros Egresos De La Explotación" Departament):

   

32020410 2000
32020411 2000
32020411RG012000
32020411RG032000
32020411RG042000
32020411RG052000
32020411RG072000
32020411RG082000
32020411RG092000

The sum of those accounts are 3.358.648

6.809.552 - 3.358.648 = 3.450.904


I prepared an excel analisis with what I want to obtain. "Otros Ingresos Fuera De La Explotación" There is to substract "Otros Egresos De La Explotación" Department.


formulas in "Operaciones" and "Casa Matriz" Departments Works Fine.


Thanks!