Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
jelly_gvm
Contributor

If condition issue

Hi All,

below is my issue highlighted in red.

LOAD MESSAGE_CODE

     MESSAGE_DESC,

   if(Len(MESSAGE_CODE)>0, MESSAGE_DESC,MESSAGE_CODE)) as Details

FROM $(path)MESSAGE_CODES.qvd;

if the MESSAGE_CODE is exists then display MESSAGE_DESC dimension values else display MESSAGE_CODE dimension values, but it is displaying always MESSAGE_CODE dimension values in the report.

Can any one suggest me.

Thanks in advance.

Regards,

Ram

1 Solution

Accepted Solutions

Re: If condition issue

Try this may be:

LOAD MESSAGE_CODE

     MESSAGE_DESC,

   if(Len(Trim(MESSAGE_CODE))>0, MESSAGE_DESC,MESSAGE_CODE)) as Details

FROM $(path)MESSAGE_CODES.qvd;

14 Replies

Re: If condition issue

Try this may be:

LOAD MESSAGE_CODE

     MESSAGE_DESC,

   if(Len(Trim(MESSAGE_CODE))>0, MESSAGE_DESC,MESSAGE_CODE)) as Details

FROM $(path)MESSAGE_CODES.qvd;

Re: If condition issue

Having given a recommendation, it just doesn't make sense that when MESSAGE_CODE is not available then you want to use it for details? Are you sure you don't want this?

LOAD MESSAGE_CODE

     MESSAGE_DESC,

   if(Len(Trim(MESSAGE_CODE))>0, MESSAGE_CODE,MESSAGE_DESC)) as Details

FROM $(path)MESSAGE_CODES.qvd;

Not applicable

Re: If condition issue

Hi,

As suggested by Sunny, you can try using Trim functions as your Condition.

Also, worth checking how are your values in 'MESSAGE_CODE' coming in QV and if you are getting '0' ?

It could sometimes be an issue with the Flag/ Binary numbers,

Try using Exists () function in your Condition.

Hope it helps !

Cheers !

jelly_gvm
Contributor

Re: If condition issue

Thanks for your reply,

Nope, when ever the MESSAGE_CODE is exiting in same field then populate the MESSAGE_DESC values else populate MESSAGE_CODE and we should not use any hard-code values to this fields.


Thanks & Regards,

Ram

jelly_gvm
Contributor

Re: If condition issue

it's not working my requirement could please change the IF condition.

Re: If condition issue

May be this:

LOAD MESSAGE_CODE

     MESSAGE_DESC,

   if(Len(Trim(MESSAGE_DESC))>0, MESSAGE_DESC,MESSAGE_CODE)) as Details

FROM $(path)MESSAGE_CODES.qvd;

Not applicable

Re: If condition issue

According to me, there is no sense in the expression you are using because you check against null on the MESSAGE_CODE and again give the null value if condition is false. Try to use below cond:

IF(LEN(TRIM(MESSAGE_DESC)),MESSAGE_DESC,MESSAGE_CODE)

MVP
MVP

Re: If condition issue

Hi,

This should definitely work, check again

TableName:

LOAD MESSAGE_CODE

     MESSAGE_DESC,

   If(Len(Trim(MESSAGE_DESC))>0, MESSAGE_DESC,MESSAGE_CODE)) as Details

FROM $(path)MESSAGE_CODES.qvd;

Regards,

Jagan.

neetha_p
Honored Contributor

Re: If condition issue

Hi Ram,


Try below code:



if(Len(Trim(MESSAGE_CODE))>0, MESSAGE_DESC,MESSAGE_CODE)) as Details


Regards

Neetha

Community Browser