Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
kishorj1982
Creator II
Creator II

Removing Nested If in script.

Hi all,

Can you please suggest , how to remove nested if else in below script.

if(GetSelectedCount(AREA)<>1 and GetSelectedCount(Entity)<>1 and GetSelectedCount(Company)<>1  and GetSelectedCount(Region_Prototype)<>1 and GetSelectedCount([Sub Region])<>1 and

GetSelectedCount(BranchOfficeDesc)<>1  and GetSelectedCount(LOBDescription)<>1 and GetSelectedCount(CustNo)<>1,'AREA',

If

(GetSelectedCount(AREA)>0 and GetSelectedCount(Entity)<>1 and GetSelectedCount(Company)<>1 

and GetSelectedCount(Region_Prototype)<>1 and GetSelectedCount([Sub Region])<>1 and

GetSelectedCount(BranchOfficeDesc)<>1  and GetSelectedCount(LOBDescription)<>1 and

GetSelectedCount(CustNo)<>1,'Entity',

If(

GetSelectedCount(Entity)>0 and GetSelectedCount(Company)<>1  and GetSelectedCount(Region_Prototype)<>1 and GetSelectedCount([Sub Region])<>1 and

GetSelectedCount(BranchOfficeDesc)<>1  and GetSelectedCount(LOBDescription)<>1 and GetSelectedCount(CustNo)<>1,'Company',

If(GetSelectedCount(Company)>0  and GetSelectedCount(Region_Prototype)<>1 and

GetSelectedCount([Sub Region])<>1 and GetSelectedCount(BranchOfficeDesc)<>1  and GetSelectedCount(LOBDescription)<>1 and GetSelectedCount(CustNo)<>1,'Region_Prototype',

if(GetSelectedCount(Region_Prototype)>0 and GetSelectedCount([Sub Region])<>1 and GetSelectedCount(BranchOfficeDesc)<>1  and

GetSelectedCount(LOBDescription)<>1 and GetSelectedCount(CustNo)<>1,'[Sub Region]',

if(

GetSelectedCount([Sub Region])>0 and GetSelectedCount(BranchOfficeDesc)<>1  and

GetSelectedCount(LOBDescription)<>1 and GetSelectedCount(CustNo)<>1,'BranchOfficeDesc',

If(GetSelectedCount(BranchOfficeDesc)>0,'CustNo',

if(GetSelectedCount(Entity)<>1 and GetSelectedCount(Company)<>1 

and GetSelectedCount(Region_Prototype)<>1 and GetSelectedCount([Sub Region])<>1 and

GetSelectedCount(BranchOfficeDesc)<>1  and GetSelectedCount(LOBDescription)<>1 and

GetSelectedCount(CustNo)<>1,'Entity',

if(GetSelectedCount(Region_Prototype)<>1 and

GetSelectedCount([Sub Region])<>1 and GetSelectedCount(BranchOfficeDesc)<>1  and GetSelectedCount(LOBDescription)<>1 and GetSelectedCount(CustNo)<>1,'Region_Prototype',

if(GetSelectedCount([Sub Region])<>1 and GetSelectedCount(BranchOfficeDesc)<>1  and

GetSelectedCount(LOBDescription)<>1 and GetSelectedCount(CustNo)<>1,'[Sub Region]',

if(GetSelectedCount(BranchOfficeDesc)<>1  and

GetSelectedCount(LOBDescription)<>1 and GetSelectedCount(CustNo)<>1,'BranchOfficeDesc','CustNo'

)

)

)

)

)

)

)

)

)

)

)

Thanks

1 Reply
Anil_Babu_Samineni

I am explaining about one part

Create one variable for this

GetSelectedCount(AREA)<>1 and GetSelectedCount(Entity)<>1 and GetSelectedCount(Company)<>1  and GetSelectedCount(Region_Prototype)<>1 and GetSelectedCount([Sub Region])<>1 and

GetSelectedCount(BranchOfficeDesc)<>1  and GetSelectedCount(LOBDescription)<>1 and GetSelectedCount(CustNo)<>1

And then Use Same variable into Qlikview in variable overview (Ctrl + Alt + V)

1) create 10 variables for each and every statement

2) Then use Pick Match condition like, I am 100% sure here, If condition kills the performance rather than Pick & Match combination

Pick(Match($(Var1), $(Var2), $(Var3), $(Var4), $(Var5), $(Var6), $(Var7), $(Var8), $(Var9), $(Var10)), 'Area', 'Entity', 'Company', 'Region_Prototype', 'Sub Region', 'CustNo', 'Entity', 'Region_Prototype', 'Sub Region', 'CustNo')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful