Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Rsaiq
Creator
Creator

Help in Qliksense set analysis for using if statement

Hi,

 

I am trying to create an set analysis like below and it is working fine as i am trying run that expression only when we have version=0 & Account=Sales,Finance & Warehouse.

=num(RangeSum(Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}
>} amount1),
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}>} amount2),
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}>} amount3))/
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}>} amount4),'$#,##0.0')

Now,I need to add 1 more filter in set analysis with if statement like below.I have added criteria as run this expression when we have document type ending with 'SA', 'AB', 'WY'.So I tried to add like below but its not working.


num(RangeSum(Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'},vDocumentType=if(RIGHT($(vDocumentType), 2)='SA' or RIGHT($(vDocumentType), 2)='WA' or RIGHT($(vDocumentType), 2)='ZA',$(vDocumentType))
>} amount1),
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'},vDocumentType=if(RIGHT($(vDocumentType), 2)='SA' or RIGHT($(vDocumentType), 2)='WA' or RIGHT($(vDocumentType), 2)='ZA',$(vDocumentType))>} amount2),
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'},vDocumentType=if(RIGHT($(vDocumentType), 2)='SA' or RIGHT($(vDocumentType), 2)='WA' or RIGHT($(vDocumentType), 2)='ZA',$(vDocumentType))>} amount3))/
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'},vDocumentType=if(RIGHT($(vDocumentType), 2)='SA' or RIGHT($(vDocumentType), 2)='WA' or RIGHT($(vDocumentType), 2)='ZA',$(vDocumentType))>} amount4),'$#,##0.0')

How we can introduce if statement in set analysis ,could you please look into it and assist me.

Thanks in advance

Labels (3)
1 Solution

Accepted Solutions
brunobertels
Master
Master

 

Hi 

May be like this 

IF( 

wildmatch( RIGHT($(vDocumentType), 2),'SA', 'AB', 'WY') , 

 

num(RangeSum(Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}
>} amount1),
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}>} amount2),
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}>} amount3))/
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}>} amount4),'$#,##0.0')

, null() 

)

 

View solution in original post

2 Replies
brunobertels
Master
Master

 

Hi 

May be like this 

IF( 

wildmatch( RIGHT($(vDocumentType), 2),'SA', 'AB', 'WY') , 

 

num(RangeSum(Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}
>} amount1),
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}>} amount2),
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}>} amount3))/
Sum({$<VERSION={0},ACCOUNT={'Sales','Finance','Warehouse'}>} amount4),'$#,##0.0')

, null() 

)

 

Rsaiq
Creator
Creator
Author

Thanks @brunobertels ,its working fine...