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: 
csmqlik01
Contributor III
Contributor III

Nested If with getfieldselections not working

Hi,

I'm trying to use getfieldselections in an expression,  to get the user's selection of the company code.

Because I have multiple possibilities, I use a nested if. But it works for only for one nested if, when I add another 'if' I get a error in the expression.  is there a restriction in use, because separate the syntax is working.

=if(GetFieldSelections([Company Code])= ' ',Sum({$<[Customer Code]=E({1<[NoFilter]={'Intercompany-4'}>})>}Quantity)

,if(GetFieldSelections([Company Code],'+',2)='BE04','US12',Sum({$<[Customer Code]=E({1<[Filter BE04/US12]={'Intercompany-4'}>})>}Quantity))

,if(GetFieldSelections([Company Code],'+',2)='BE04','US29',Sum({$<[Customer Code]=E({1<[Filter BE04/US29]={'Intercompany-4'}>})>}Quantity))

,if(GetFieldSelections([Company Code],'+',2)='US12','US29',Sum({$<[Customer Code]=E({1<[Filter US12/US29]={'Intercompany-4'}>})>}Quantity)))

or

=if(GetFieldSelections([Company Code],',',2)='BE04','US12',Sum({$<[Filter BE04/US12]=-{'Intercompany-4'}>}Quantity)

,if(GetFieldSelections([Company Code],',',2)='BE04','US29',Sum({$<[Filter BE04/US29]=-{'Intercompany-4'}>}Quantity))

With both I get an error, can anyone say what the problem is

Or is it better to use pick match ..;  but how is the syntax to get the same result

Br

1 Solution

Accepted Solutions
sunny_talwar

Super... Please close this thread by marking correct and helpful responses

Qlik Community Tip: Marking Replies as Correct or Helpful

Best,

Sunny

View solution in original post

18 Replies
shraddha_g
Partner - Master III
Partner - Master III

Try

if(wildmatch(GetFieldSelections([Company Code],',',2),'BE04','US12'),Sum({$<[Filter BE04/US12]=-{'Intercompany-4'}>}Quantity),

if(wildmatch(GetFieldSelections([Company Code],',',2),'BE04','US29'),Sum({$<[Filter BE04/US29]=-{'Intercompany-4'}>}Quantity))

csmqlik01
Contributor III
Contributor III
Author

Hi,

Thanks for the quick answer, but still an error in the expression

=if(WildMatch(GetFieldSelections([Company Code],',',2)='BE04','US12',Sum({$<[Filter BE04/US12]=-{'Intercompany-4'}>}Quantity))

,if(WildMatch(GetFieldSelections([Company Code],',',2)='BE04','US29',Sum({$<[Filter BE04/US29]=-{'Intercompany-4'}>}Quantity))))

Br

agigliotti
Partner - Champion
Partner - Champion

you should provide a sample qvf to show what you are looking for...

shraddha_g
Partner - Master III
Partner - Master III

Try,

if(wildmatch(GetFieldSelections([Company Code]),'BE04','US12'),Sum({$<[Filter BE04/US12]=-{'Intercompany-4'}>}Quantity),

if(wildmatch(GetFieldSelections([Company Code],'BE04','US29'),Sum({$<[Filter BE04/US29]=-{'Intercompany-4'}>}Quantity))

csmqlik01
Contributor III
Contributor III
Author

Hi,

Same result error

@Andrea  provide a qvf is difficult, sensitive data, I have to create a small qvf with sample data.  But I get a syntax error in the expression so I'm not that far to get a result in my Pivot table

Br

sunny_talwar

If statement goes like this

If(Something = Something, True,

    If(Something2 = Something2, True, False)

Now, I am not sure your if statement is doing that

=if(GetFieldSelections([Company Code],',',2)='BE04','US12',Sum({$<[Filter BE04/US12]=-{'Intercompany-4'}>}Quantity)

,if(GetFieldSelections([Company Code],',',2)='BE04','US29',Sum({$<[Filter BE04/US29]=-{'Intercompany-4'}>}Quantity))

Now what I am not sure is what is US12? Are you checking for 2 things BE04 and US12? If that is what you want, then may be this

=if(GetFieldSelections([Company Code],',',2)='BE04, US12', Sum({$<[Filter BE04/US12]=-{'Intercompany-4'}>}Quantity), if(GetFieldSelections([Company Code],',',2)='BE04, US29', Sum({$<[Filter BE04/US29]=-{'Intercompany-4'}>}Quantity))

csmqlik01
Contributor III
Contributor III
Author

Hi Sunny,

indeed I'm checking for BE04 and US12, so maybe I have to put it between ()

=if(GetFieldSelections([Company Code],'+',2)=('BE04',US12')...

And when I understand it, the last if, has to include a false statement, so could be " sum(Quantity) " if I have that requirement,

if(GetFieldSelections([Company Code]),('BE04','US12'),Sum({$<[Filter BE04/US12]=-{'Intercompany-4'}>}Quantity),

if(GetFieldSelections([Company Code],('BE04','US29'),Sum({$<[Filter BE04/US29]=-{'Intercompany-4'}>}Quantity, Sum(Quantity)))))

but it still gives an error

Br

sunny_talwar

Did you check this?

=If(GetFieldSelections([Company Code], ',', 2) = 'BE04, US12', Sum({$<[Filter BE04/US12]=-{'Intercompany-4'}>}Quantity), If(GetFieldSelections([Company Code], ',', 2) = 'BE04, US29', Sum({$<[Filter BE04/US29]=-{'Intercompany-4'}>}Quantity))

sunny_talwar

Also, the last if doesn't need to include a false statement.... you can actual leave it blank....