Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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

18 Replies
csmqlik01
Contributor III
Contributor III
Author

Hi,

For the two first lines it works ,  I added one bracket at the end

but now I added a third line and then I get an error

=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))

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

csmqlik01
Contributor III
Contributor III
Author

oeps I mistyped no error anymore

=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)

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

sunny_talwar

So all working now?

csmqlik01
Contributor III
Contributor III
Author

Hi,

I have no syntax error but in the chart I get no result with  'BE04, US12'  and If I add quotes 'BE04', 'US12' I get no syntax error and have result also for one if, if I add another if I get an error in expression

So it seems to be a problem with multiple selections

sunny_talwar

It all boils down to your condition... create a text box object with the following expression -> GetFieldSelections([Company Code], ',', 2) What do you see when you make selection? Do you see BE04, US12 or do you see something else?

csmqlik01
Contributor III
Contributor III
Author

I tried two textboxes ,

sunny_talwar

So there is no space after comma... try 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)

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

csmqlik01
Contributor III
Contributor III
Author

Thanks Sunny

that's the correct syntax, no error in expression and result as required

If(GetFieldSelections(Field,','2)='Selection1,Selection2', ....

No spaces and between quotes

Thanks again for your help

Best regards

sunny_talwar

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

Qlik Community Tip: Marking Replies as Correct or Helpful

Best,

Sunny