Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Selections in Set Analysis

Hi,

I'm trying to create some set analysis code which which executes two different sums on different metrics depending on the outcome of an IF statement.

Basically if dimensions Name or Area are selected by the user from their respective List Boxes, I want to get the sum of Sales. Otherwise I want to sum the Sales Forecast.

I have written it in the following way:

if([Name]='*' and [Area]= '*',

sum({<Month={$(=month(max([Mth Yr])))}, Year={$(=max(Year)), [Day Type]={0}>} [Sales Forecast]),

sum({<Month={$(=month(max([Mth Yr])))}, Year={$(=max(Year))}>}[Sales Amount]))


The IF statement does not work - how do I incorporate selections from List Boxes in the script?


Thanks in advance.

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

Replace the if by,

if(GetSelectedCount(Name)>0 And GetSelectedCount(Area) > 0, <Forecast>, <Sales>)

Regards,

Prabhu

View solution in original post

5 Replies
tresesco
MVP
MVP

Try using GetFieldSelections(), like:

If ( GetFieldSelections(Name)>0 and GetFieldSelections(Area)>0 , ...., ....)

Not applicable
Author

Hi,

Replace the if by,

if(GetSelectedCount(Name)>0 And GetSelectedCount(Area) > 0, <Forecast>, <Sales>)

Regards,

Prabhu

Not applicable
Author

try this

if(len([Name])>0 or len([Area])>0,

sum({<Month={$(=month(max([Mth Yr])))}, Year={$(=max(Year)), [Day Type]={0}>} [Sales Forecast]),

sum({<Month={$(=month(max([Mth Yr])))}, Year={$(=max(Year))}>}[Sales Amount]))


Thank you

Vardhan

amit_saini
Master III
Master III

Hi Royale,

Try this (Here I'm considering my selection for Plant list)

='Customer Stoppers'&chr(32)&if(GetSelectedCount(Plant)>0,'- '&GetFieldSelections(Plant)&'')

Thanks,

AS

Not applicable
Author

Thank you all for your replies, much appreciated, all useful answers. I used the GetSelectedCount solution from Prabhu, thanks!