Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis Query


Hi,

I have a scenario wherein There are columns ID, Flag and B_Calc.

I have to calculate sum of a B_Calc for the Least Flag value  for each ID in a Pivot table.

How can I achieve in Set Analysis ?

Eg.

FlagID
-11
01
-13
04

B_CalcFlagID
1-11
201
300-11
543-13
12704

The result should look something like :

Sum(B_Calc)FlagID
301-11
543-13
12704
1 Solution

Accepted Solutions
Not applicable
Author

Thanks Gysbert !

However I tried using Set Analysis in the Pivot Expression to get the desired result;

sum({<Flag={'-1','0','*'} ,Flag={'-1'},Flag={'0'}>}B_Calc)

Cheers !

View solution in original post

6 Replies
its_anandrjs
Champion III
Champion III

Hi,

Write expression

Sum({<Flag={'<=$(=0)'}>} B_Calc)

Regards

Anand

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See attached qvw.


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks Gysbert !

However I tried using Set Analysis in the Pivot Expression to get the desired result;

sum({<Flag={'-1','0','*'} ,Flag={'-1'},Flag={'0'}>}B_Calc)

Cheers !

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Check the sum for ID 1. It'll be 303 instead of 301.

sum({<Flag={'-1','0','*'} ,Flag={'-1'},Flag={'0'}>}B_Calc) is the same as sum({<Flag={'*'}>}B_Calc) and in this case it's also the same as sum(B_Calc).


talk is cheap, supply exceeds demand
Not applicable
Author

Hi,

Thanks for pointing it out !

I Tried using '*' to ensure if a Flag is not assosiated but has B_Cal Value against it as the Columns in my actual App reside in different Tables.

The Change I did is :

sum

({<Flag={'-1','0'} ,Flag={'-1'}>}B_Calc)

Thanks !

sushil353
Master II
Master II

Hi,

there is another way..

in your script you can calculate an extra file say countflag:

LOAD AutoNumber(flag,id) as countflag,* Inline
[
flag,id
-1, 1
0 ,1
-1 ,3
0 ,4
]
;

and then in your expression simply use: Sum({<countflag={1}>}B_Cal)

HTH

Sushil