# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for
Did you mean:
Not applicable

## sum if

 CCY Amount INR -200 INR -250 EUR 0 USD 400 USD -300 USD -150

Total AmountTotal Amount in USD
-500-50

I want to use sum if but my logic seems to be not working - can you help?

My script:

sum(Amount) as Total,

if(CCY = 'USD', sum(Amount)) as TotalUSD

Resident Table;

The if condition does not return any value.

1 Solution

Accepted Solutions
MVP

Hi,

Try like this

DataTemp:

*,

Amount

if(CCY = 'USD', Amount, 0) as TotalUSD

Resident Table;

Data:

Sum(Amount) AS Amount,

Sum(TotalUSD) AS TotalUSD

RESIDENT DataTemp;

DROP TABLE DataTemp;

Hope this helps you.

Regards,

Jagan.

5 Replies
Not applicable
Author

Try

Sum( if(CCY = 'USD', Amount)) as TotalUSD

Not applicable
Author

Still does not work -> getting no output for TotalUSD

Specialist

HI ,

use this

if(CCY='USD',Amount) as TotalUSD

As you are using aggrgation function the use group by too.

like.

a,

b,

sum(Amount) as Total,

if(CCY='USD',Amount) as TotalUSD

from tableabc group by a,b;

Thanks.

MVP

Hi,

Try like this

DataTemp:

*,

Amount

if(CCY = 'USD', Amount, 0) as TotalUSD

Resident Table;

Data:

Sum(Amount) AS Amount,

Sum(TotalUSD) AS TotalUSD

RESIDENT DataTemp;

DROP TABLE DataTemp;

Hope this helps you.

Regards,

Jagan.

Creator II

A straight table with no Dim and these expressions will also do it:

=sum(Amount)

=sum({<CCY={'USD'}>}Amount)

Community Browser