New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Highlighted
Not applicable

if condition help

Hi Experts,

I have the below expression

Expression : =Sum(AGGR((if(Branch='1',[Target]*3,if(sum({<[Group]={'01'}>}Sales)=0,0,[Target]),Branch,Month))

i m trying to apply condition like, if the branch is 1, then i should bring target*3, if sum(sales) for group 01 is 0, then it should give zero, else target.

i m not getting correct values on total.

i couldnt find out what is wrong in my expression.

Tags (1)
1 Solution

Accepted Solutions
Highlighted
Employee

Re: if condition help

First, you have a mismatch in the number of brackets. If I correct that, your expression will look like

Sum(

AGGR(

if(

Branch='1',

[Target]*3,

if(

sum({<[Group]={'01'}>}Sales)=0,
0,

[Target]
)
),

Branch,

Month
)
)

The next problem is that you use naked field references, when you need aggregation functions. These are marked in red. See Use Aggregation Functions!

Finally, I am not sure you need the Aggr(). I would in any case start without the Aggr() so I know that the base calculation works.

HIC

2 Replies
Highlighted
Employee

Re: if condition help

First, you have a mismatch in the number of brackets. If I correct that, your expression will look like

Sum(

AGGR(

if(

Branch='1',

[Target]*3,

if(

sum({<[Group]={'01'}>}Sales)=0,
0,

[Target]
)
),

Branch,

Month
)
)

The next problem is that you use naked field references, when you need aggregation functions. These are marked in red. See Use Aggregation Functions!

Finally, I am not sure you need the Aggr(). I would in any case start without the Aggr() so I know that the base calculation works.

HIC

Highlighted
Not applicable

thanks henric