Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
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.

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

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
hic
Former Employee
Former Employee

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

Not applicable
Author

thanks henric