Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jelly_gvm
Creator
Creator

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
sunny_talwar

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;

View solution in original post

14 Replies
sunny_talwar

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;

sunny_talwar

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

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
Creator
Creator
Author

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
Creator
Creator
Author

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

sunny_talwar

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

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)

jagan
Luminary Alumni
Luminary Alumni

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.

Anonymous
Not applicable

Hi Ram,


Try below code:



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


Regards

Neetha