Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
EderMachado1
Contributor II
Contributor II

Is there any way to improve this series of If Else statements?

Hello Qlik Gurus!

Right now we're having some serious issues with one of our document's performance, particularly due to a lengthy set analysis in a specific bar chart which does what the user needs it to do via a series of If Else statements. As I said, this document drags the performance down so due to all the user comments we need to do something to fix it.

 

=if(GetSelectedCount(CodigoCompleto)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={17},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo3),
if(GetSelectedCount(ProveedorCompleto)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={17},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo4),
If(GetSelectedCount(FamiliaCompleta)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={15},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo3),
if(GetSelectedCount(ClaseCompleta)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={15},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo2),
if(GetSelectedCount(SubcategoriaCompleta)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={16},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo1),
if(GetSelectedCount(CategoriaCompleta)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={15},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo4),
if(GetSelectedCount(Comprador)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={16},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo2),
if(GetSelectedCount(Coordinador)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={16},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo4),
If(GetSelectedCount(GerenteNacional)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={17},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo1),

if(GetSelectedCount(Coordinador)=1 and GetSelectedCount(CodigoCompleto)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={17},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo3),
if(GetSelectedCount(Coordinador)=1 and GetSelectedCount(ProveedorCompleto)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={17},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo4),
If(GetSelectedCount(Coordinador)=1 and GetSelectedCount(FamiliaCompleta)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={15},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo3),
if(GetSelectedCount(Coordinador)=1 and GetSelectedCount(ClaseCompleta)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={15},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo2),
if(GetSelectedCount(Coordinador)=1 and GetSelectedCount(SubcategoriaCompleta)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={16},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo1),
if(GetSelectedCount(Coordinador)=1 and GetSelectedCount(CategoriaCompleta)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={15},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo4),
if(GetSelectedCount(Coordinador)=1 and GetSelectedCount(Comprador)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={16},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo2),
If(GetSelectedCount(Coordinador)=1 and GetSelectedCount(GerenteNacional)=1,max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={17},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo1),


max({<Fecha_Corte=,TipoPeriodo={1},Periodo=,AnioPeriodo=,IdTipo={15},IdDimension={1},Estado=,NombreTienda=,Cedis=>}Campo1)
)))))))))))))))))


 

This is an example of one of the sentences the chart uses as an expression.

As you can see, depending of what specific field is selected we need to do a different set analysis, adding an iteration for if an specific field (Coordinador) is also selected... and there's 12 of these expressions. Of course, some of these are conditional triggered so not all of them are calculated at the same time but at a minimum there's 3 of these series of set analysis active at the same time showing 3 different bars/lines. The only idea I came up with is to separate said 12 different expressions into 4 different charts with calculation and show conditionals, and make each and every single IfElse statement an individual expression with the "ifelse" conditional being put inside the "Calculation Condition" field, but it will be a massive amount of work. Is there a simpler way to do what I'm trying to do? I can provide more info or more examples if needed.

Thank you all for reading! 

Labels (2)
0 Replies