Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis Query

Hi There,

I'm wondering if anyone is able to assiste with the following query I need to run through set analysis

SELECT SUM(mems) FROM
(
( SELECT count(*) AS mems
FROM table1
WHERE date_range BETWEEN min(report_date) and max(report_date)
AND status = 'C'
AND (channel <> old_channel
OR package <> old_package_id)
GROUP BY package, channel, pmi
HAVING package <> 14
)
)

Thanks,

Kevin.

2 Replies
prieper
Master II
Master II

Hi,

not quite clear to me, what your intention is and which is the relation to set-analysis.

Peter

johnw
Champion III
Champion III

Almost impossible for me to get this right on the first try without an example QVW to test it on and some more information, such as if old_channel and old_package_id are single values or a list of values, but something like this?

sum(aggr(count({<date_range={">=$(=date(min(report_date))) <=$(=date(max(report_date)))"}
,status={C}
,package-={14}
>}
if(channel <> old_channel
or package <> old_package_id,1))
,package,channel,pmi))

I implemented your OR without using set analysis. You CAN do a union of two sets, but I frankly expect that the performance would be worse than just doing the OR separately.

By the way, if I understand your SQL, the "having package <> 14" isn't any different than just putting that in as another condition in the select. I believe having is normally used when you need to check the RESULT of the SQL, such as if you wanted "having mems > 20".