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

MINUS in QlikView

Hi,

Could some one help us in extracting the same output as that provided by MINUS keyword in Oracle.

I have elaborated the issue with an example below:

Main Query o/p:

YearDivisionD_ENTRY_DATECurrencyTypeAmount
04A102/05/2007USDR-40338.4
04A202/05/2007USDC271453
04A323/05/2007USDC55.73
06A318/09/2008USDR-793.36
06A313/05/2009USDR810.39
04A330/11/2009USDC345.14
04A330/11/2009USDR-52.15
05A301/07/2010USDT1.6
04A126/03/2010USDT0.4
05A226/03/2010USDT1.6

Minus Query o/p:

YearDivisionD_ENTRY_DATECurrencyTypeAmount

No rows returned based on the below conditions(there are no records with Type as 'P'):

Where Type = 'P' And Division in ('A1', 'A2') And Year In ('05','06')

To get the similar output in QlikView, we have used the conditions of Minus Query as - (Exclusion) in Set Analysis.

sum({$<[Type] -= {'P'}, [Policy Year] -= {'05', '06'}, [Division Code]-={'A1', 'A2'}>} Amount)

The sum results in zero for the last 3 rows above.

YearDivisionD_ENTRY_DATECurrencyTypeAmount
05A301/07/2010USDT0
04A126/03/2010USDT0
05A226/03/2010USDT0

Please advise if the conditions in the set analysis have been included correctly. Also, we need to exclude the rows that match with the above conditions.

Regards,
Rajendra

1 Solution

Accepted Solutions
sbaldwin
Partner - Creator III
Partner - Creator III

Hi i am not sure your set algebra is quite right as by adding you minus querys to the same set modifyer you are essentially saying AND, but you are modifying it with not conditions, have you tried something like:

({$- $<[Type] = {'P'}, [Policy Year] = {'05', '06'}, [Division Code]={'A1', 'A2'}>}

so you are taking the entire "Minus" set and taking it from the current selection?

(that is if i understand you correctly!!! )

Thanks

Steve

View solution in original post

5 Replies
sbaldwin
Partner - Creator III
Partner - Creator III

Hi i am not sure your set algebra is quite right as by adding you minus querys to the same set modifyer you are essentially saying AND, but you are modifying it with not conditions, have you tried something like:

({$- $<[Type] = {'P'}, [Policy Year] = {'05', '06'}, [Division Code]={'A1', 'A2'}>}

so you are taking the entire "Minus" set and taking it from the current selection?

(that is if i understand you correctly!!! )

Thanks

Steve

Not applicable
Author

Thanks Steve,

This helped in the exclusion of the rows. However we are unable to find how to apply OR operator in set analysis.

Could you please help us in applying OR operator in Set analysis.

Example in SQL:

WHERE Group = 'PR' AND DivisionCode IN ('A1', 'A2') AND (Type  !=  'Batch PNP'
OR

(Type  =  'Batch PNP'
AND 
Year IN ('05', '06')))

This when converted in Set analysis as a negate would be:

({$- $<[Group] = {'P'}, [DivisionCode]={'A1', 'A2'},[Year] = {'05', '06'},[Type] = {'Batch PNP'}>}

How to apply Type  !=  'Batch PNP' and the OR condition?

Could you please advise.

sbaldwin
Partner - Creator III
Partner - Creator III

Hi in set analysis this is a union so you would need to do something like this:

({    ($- $<[Group] = {'P'}, [DivisionCode]={'A1', 'A2'},[Year] = {'05', '06'},[Type] = {'Batch PNP'}>)+$<Type  -= { 'Batch PNP'>   }

Thanks

Steve

Not applicable
Author

Thanks Steve,

Almost there, but looks like I am missing something.

It is mentioned that

A AND (B OR C)

Becomes:

(A AND B) OR (A AND C)

Which becomes something like:

{$<A, B> + {<A, C>}

When I apply the filter as advised by you, it is displaying data only based on the 1st filter.

Formula 1:

sum({(1- $<[V_HOW_MADE_PAYABLE_SDESC] -= {'Batch PNP'}>)+$<[V_TOE_GROUP] = {'PR'}, [V_POLICY_YEAR]={'05', '06', '07', '08', '09', '10'},

[V_DIVISION_CODE] = {'E', 'F','O'},

[V_TOE_MCD] = {'08', '10', '12', '14', '16'},

[V_HOW_MADE_PAYABLE_SDESC] = {'Batch PNP'}>} AMOUNT)

Shows data only matching with

'Batch PNP'

Formula 2:

sum({($- $<[V_TOE_GROUP] = {'PR'}, [V_POLICY_YEAR]={'05', '06', '07', '08', '09', '10'},

[V_DIVISION_CODE] = {'E', 'F', 'O'},

[V_TOE_MCD] = {'08', '10', '12', '14', '16'},

[V_HOW_MADE_PAYABLE_SDESC] = {'Batch PNP'}>)+$<[V_HOW_MADE_PAYABLE_SDESC] -= {'Batch PNP'}>} AMOUNT)

Does not filter out the rows with 'Batch PNP'

Could you please advise the correct syntax that needs to be followed.

Not applicable
Author

Steve,

Just wanted to updated that the syntax to be followed equilvent to the above SQL query is:

Sum ({1-($<[Type] -= {'Batch PNP'}> + $<[Group] = {'PR'}, [Year]={'05', '06'},

[Division Code] = {'A1', 'A2'},

[Type] = {'Batch PNP'}>)} Amount)

Thanks for you help on this.