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: 
Not applicable

Condition fails to proceed

Hi All,

Below is the condition used in my code

    if(ApplyMap('WBS_Des_MAP',[WBS Element],0)<>0, [WBS Element],

     if(len(trim(Assignment))>6,if(ApplyMap('WBS_Des_MAP',Assignment,0)<>0,Assignment,

     if(len(trim(H.Text))<>0, H.Text,

     if(ApplyMap('WBS_Des_MAP',[Project Code],0)<>0,[Project Code]   

     )))))   

     as WBS_Final_Code

As per my Understanding "If there is any mapping with WBS_Des_MAP then it will choose [WBS Element] from this table else it will check for next statement" Similarly for other statements. Please correct me if i am wrong.

But i don't know why the above condition is failing. It just checks at first statement is mapping is available then [WBS Element] else it results empty.

Please help me with this.

Regards,

Keerthi KS

1 Solution

Accepted Solutions
Not applicable
Author

Hi Jonathan,

I understood the mistake.

if(ApplyMap('WBS_Des_MAP',[WBS Element],0)<>0

  ,[WBS Element]

  ,

  //

  if(len(trim(Assignment))>6 and ApplyMap('WBS_Des_MAP',Assignment,0)<>0

  ,Assignment

  ,

  if(len(trim(H.Text))<>0

  ,H.Text

  ,

  if(ApplyMap('WBS_Des_MAP',[Project Code],0)<>0

  ,[Project Code]

))))

Thanks,

Keerthi KS

View solution in original post

3 Replies
Not applicable
Author

Hi,

Your first applymap itself is with both true and false condition.

if(ApplyMap('WBS_Des_MAP',[WBS Element],0)<>0, [WBS Element]

here if [WBS Element] <>0 ,[WBS Element]

else 0

so this first condition will always execute for a true/false value.

so "If there is any mapping with WBS_Des_MAP then it will choose [WBS Element] from this table else it will return 0".


Hope it helps!


Kiruthi



jonathandienst
Partner - Champion III
Partner - Champion III

Two of the Ifs do not have else conditions (highlighted in bold below), so if the condition is false, the statement will return null. Re-arranged for clarity:

if(ApplyMap('WBS_Des_MAP',[WBS Element],0)<>0,

    [WBS Element],

    if(len(trim(Assignment))>6,

        if(ApplyMap('WBS_Des_MAP',Assignment,0)<>0,

            Assignment,

            if(len(trim(H.Text))<>0,

                H.Text,

               if(ApplyMap('WBS_Des_MAP',[Project Code],0)<>0,

                    [Project Code]  

                )

            )

        )

    )

) as WBS_Final_Code

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi Jonathan,

I understood the mistake.

if(ApplyMap('WBS_Des_MAP',[WBS Element],0)<>0

  ,[WBS Element]

  ,

  //

  if(len(trim(Assignment))>6 and ApplyMap('WBS_Des_MAP',Assignment,0)<>0

  ,Assignment

  ,

  if(len(trim(H.Text))<>0

  ,H.Text

  ,

  if(ApplyMap('WBS_Des_MAP',[Project Code],0)<>0

  ,[Project Code]

))))

Thanks,

Keerthi KS