Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Talk to Experts Tuesday, Live Q&A, September 22: Moving from QlikView to Qlik Sense. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

sum if

CCYAmount
INR-200
INR-250
EUR0
USD400
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:

LOAD

          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
Highlighted
MVP & Luminary
MVP & Luminary

Hi,

Try like this

DataTemp:

LOAD

     *,

          Amount

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

Resident Table;

Data:

LOAD
     Sum(Amount) AS Amount,

     Sum(TotalUSD) AS TotalUSD

RESIDENT DataTemp;

DROP TABLE DataTemp;

Hope this helps you.

Regards,

Jagan.

View solution in original post

5 Replies
Highlighted
Not applicable

Try

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

Highlighted
Not applicable

Still does not work -> getting no output for TotalUSD

Highlighted
Specialist
Specialist

HI ,

use this

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

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

like.

load

a,

b,

sum(Amount) as Total,

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

from tableabc group by a,b;

Thanks.

Highlighted
MVP & Luminary
MVP & Luminary

Hi,

Try like this

DataTemp:

LOAD

     *,

          Amount

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

Resident Table;

Data:

LOAD
     Sum(Amount) AS Amount,

     Sum(TotalUSD) AS TotalUSD

RESIDENT DataTemp;

DROP TABLE DataTemp;

Hope this helps you.

Regards,

Jagan.

View solution in original post

Highlighted
Creator II
Creator II

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

=sum(Amount)

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