Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Read about Qlik’s Response to COVID-19 Read the Letter, Join the Group.
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.

please help me to correct my expression.

Tags (1)
1 Solution

Accepted Solutions
Highlighted

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

View solution in original post

2 Replies
Highlighted

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

View solution in original post

Highlighted
Not applicable

Re: if condition help

thanks henric