Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

How to sum based on other column data

Hi I have a data like this

A B Amount_Type

1 200 ZZZ

1 300 XXX

1 500 YYY

1 300 ZZZ

I want to sum column B if Amount_Type is ZZZ in straight table.

IF(Amount_Type='ZZZ',Sum(B),) Is this correct??


Tags (1)
4 Replies
MVP
MVP

Re: How to sum based on other column data

Create a Straight Table

Dimension

Amount_Type

Expression

SUM({<Amount_Type = {'ZZZ'}>}B)             // Using Set Analysis

SUM(IF(Amount_Type = 'ZZZ',B))               // Using IF

anbu1984
Honored Contributor III

Re: How to sum based on other column data

SUM(IF(Amount_Type='ZZZ',B))

hrlinder
Honored Contributor

Re: How to sum based on other column data

donot forget to define group by

other way:

load A,

  Sum(B),

Amount_Type

resident xyz

group by Amount_Type

where Amount_Type = 'ZZZ'

bu

load A,

  if (Amount_Type='ZZZ',Sum(B)) as B

Amount_Type

resident xyz

group by Amount_Type

should do as well


Not applicable

Re: How to sum based on other column data

Try this

Temp:

Load A,

         B,

         Amount_Type

From Table;

Amount:

Load

         A,

        Sum(B) as B,

        Amount_Type
Resident Temp group by Amount_Type;

Community Browser