Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
olguita2014
Creator
Creator

How can I optimize my script

Hi,

Please help me!!!!!!!

How can I optimize the following statements:

    if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),2)=01,Left(Cod_Cuenta,10),

      if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),1)=02,Left(Cod_Cuenta,10),

        if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),1)=03,Left(Cod_Cuenta,10),

            if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),1)=04,Left(Cod_Cuenta,10),

                if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),1)=05,Left(Cod_Cuenta,10),

                    if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),1)=06,Left(Cod_Cuenta,10),

                        if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),1)=07,Left(Cod_Cuenta,10),

                            if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),1)=08,Left(Cod_Cuenta,10),

                                if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),1)=09,Left(Cod_Cuenta,10),

                                    if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),2)=10,Left(Cod_Cuenta,10),

                                        if(Len(Cod_Cuenta)=12 and Right(Left(Cod_Cuenta,10),2)=11,Left(Cod_Cuenta,10)

                                            )

                                        )

                                    )

                                )

                            )

                        )

                    )

                )

            )

        )

      

    )

1 Solution

Accepted Solutions
aarkay29
Specialist
Specialist

your exp can be written as below in short but it would not  give you much of a performance boost .

if(Len(Cod_Cuenta)=12,

     If( 

          Match(Right(Left(Cod_Cuenta,10),2),'01','10','11')

          or

          Match(Right(Left(Cod_Cuenta,10),1),'2','3','4','5','6','7','8','9'),Left(Cod_Cuenta,10)

          )

     )

View solution in original post

5 Replies
aarkay29
Specialist
Specialist

your exp can be written as below in short but it would not  give you much of a performance boost .

if(Len(Cod_Cuenta)=12,

     If( 

          Match(Right(Left(Cod_Cuenta,10),2),'01','10','11')

          or

          Match(Right(Left(Cod_Cuenta,10),1),'2','3','4','5','6','7','8','9'),Left(Cod_Cuenta,10)

          )

     )

olguita2014
Creator
Creator
Author

But I can not put this: '01','10','11' or ,'2','3','4','5','6','7','8','9'

I want to put Left(Cod_Cuenta,10)

sunny_talwar
MVP
MVP

May be this

if(Len(Cod_Cuenta)=12,

     If(Match(Mid(Cod_Cuenta, 9, 2), '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11'), Left(Cod_Cuenta,10)))

aarkay29
Specialist
Specialist

may be this

if(Len(Cod_Cuenta)=12,

     If(

          Not IsNull(Num(Mid(Cod_Cuenta, 9, 1))), Left(Cod_Cuenta,10)

))


Anonymous
Not applicable

I'll try!  How about:

If len(Cod_Cuenta)=12  and num(Right(Left(Cod_Cuenta,10),2))<12 and num(Right(Left(Cod_Cuenta,10),2))>0,

     left(Cod_Cuenta,10))