# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld Online 2021, May 10-12: Our Free, Virtual, Global Event REGISTER TODAY
cancel
Showing results for
Did you mean:
Contributor III

## Get Positive Value in KPI Accounting

Hello my friends I need your help

I have the following table with its expressions:

ACCNT_CODE = Accounts

Debit = Sum({<[D_C]={"D"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT])

Credit = Sum({<[D_C]={"C"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT])

Balance = Sum({<[D_C]={"D"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]) + Sum({<[D_C]={"C"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT])

As show

I want to do the sum the values that are positive in the Balance, is there a way to do this?

Labels (4)

• ### Qlik Sense

1 Solution

Accepted Solutions
MVP

@JASalinas  try below

``````=sum(aggr(if((Sum({<[D_C]={"D"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]) + Sum({<[D_C]={"C"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]))>0,

Sum({<[D_C]={"D"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]) + Sum({<[D_C]={"C"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]),0), Account))``````
8 Replies
MVP

@JASalinas  try below

Sum({<[AMOUNT]={">0"},[D_C]={"D"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]) + Sum({<[AMOUNT]={">0"},[D_C]={"C"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT])

Contributor III
Author

Hi @Kush thank for you answer, I tried but in the balance column it show me the same as the credit column.

MVP

@JASalinas  try below

if((Sum({<[D_C]={"D"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]) + Sum({<[D_C]={"C"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]))>0,

Sum({<[D_C]={"D"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]) + Sum({<[D_C]={"C"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]),0)

Contributor III
Author

Hi @Kush Well we're moving on, show me the following

The sum is equal to zero, it is not doing the sum...

MVP

@JASalinas  you can set the total function option to "sum" in measure properties

Contributor III
Author

@Kush Yes, it already does the sum, but how can I do this in KPI? The KPI does not have the sum option.

MVP

@JASalinas  try below

``````=sum(aggr(if((Sum({<[D_C]={"D"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]) + Sum({<[D_C]={"C"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]))>0,

Sum({<[D_C]={"D"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]) + Sum({<[D_C]={"C"},[ACCNT_CODE]={"12*", "13*", "14*","32*", "33*", "34*","A*", "E*", "R*"}>}[AMOUNT]),0), Account))``````
Contributor III
Author

@Kush Uff, Excelent My Friend, Thank you very very much... It's work!....