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: 
robin_heijt
Creator
Creator

If statement grouping

Hi,

I want to create a field for section access based on Bands.

These bands are: I, II, III, IV, V, VI, VII, ALL

Now I want the field to calculate the following:

if("Band Unified"='III', 'III-ALL',

//   if("Band Unified"='IV', 'III-ALL',

//   if("Band Unified"='V', 'III-ALL',

//   if("Band Unified"='VI', 'III-ALL',

//   if("Band Unified"='VII', 'III-ALL',

//   if("Band Unified"='ALL', 'III-ALL',

 

//   if("Band Unified"='V', 'V-ALL',

//   if("Band Unified"='VI', 'V-ALL',

//   if("Band Unified"='VII', 'V-ALL',

//   if("Band Unified"='ALL', 'V-ALL', 'Other')))))))))) as BANDSECURITY;

When loaded, Qlik Sense will only show the III-ALL string, and not the V-ALL string.

How would I have to make my code to have both strings in my field?

1 Solution

Accepted Solutions
sunny_talwar

Because once a condition is met, the if statement won't go any forward.... for example when "Band Unified" = 'V', then as soon as it equal to 'V' the first time... it will get 'III-ALL'... it won't need to go forward to get to 'V-ALL'. May be you need this

Table:

LOAD ...,

if("Band Unified"='III', 'III-ALL',

if("Band Unified"='IV', 'III-ALL',

if("Band Unified"='V', 'III-ALL',

if("Band Unified"='VI', 'III-ALL',

if("Band Unified"='VII', 'III-ALL',

if("Band Unified"='ALL', 'III-ALL', 'Other')))))) as BANDSECURITY

FROM ...;

Concatenate (Table)

LOAD ...,

if("Band Unified"='V', 'V-ALL',

if("Band Unified"='VI', 'V-ALL',

if("Band Unified"='VII', 'V-ALL',

if("Band Unified"='ALL', 'V-ALL',  'Other')))) as BANDSECURITY

FROM ...;

View solution in original post

2 Replies
sunny_talwar

Because once a condition is met, the if statement won't go any forward.... for example when "Band Unified" = 'V', then as soon as it equal to 'V' the first time... it will get 'III-ALL'... it won't need to go forward to get to 'V-ALL'. May be you need this

Table:

LOAD ...,

if("Band Unified"='III', 'III-ALL',

if("Band Unified"='IV', 'III-ALL',

if("Band Unified"='V', 'III-ALL',

if("Band Unified"='VI', 'III-ALL',

if("Band Unified"='VII', 'III-ALL',

if("Band Unified"='ALL', 'III-ALL', 'Other')))))) as BANDSECURITY

FROM ...;

Concatenate (Table)

LOAD ...,

if("Band Unified"='V', 'V-ALL',

if("Band Unified"='VI', 'V-ALL',

if("Band Unified"='VII', 'V-ALL',

if("Band Unified"='ALL', 'V-ALL',  'Other')))) as BANDSECURITY

FROM ...;

robin_heijt
Creator
Creator
Author

Thanks!