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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

IF condition

Hi all,

I have a scenario where there are three fields from the same table , let's say A, B, C which are Id's for a particular process.  All these fields have both number and text in them. Now, I need to get the output as when A = Null then A=B, when B = Null then B = A , when A = null and B = Null, then C else A'/'B. but I need to get the output in a filed called Reference Number .

The problem is i am not able to achieve the third If condition when A = null and B = Null, then C and show it in the Reference Number =  filed .

Below is the expression I have used.

if(len(trim(A))=0,text(B),

if(len(trim(B))=0,text(C),

if(len(trim(A))=0 and len(trim(B))=0,text(C),text(A)&'/'&text(B)))) as [Reference Number],

Thank you in Advance.

PV

7 Replies
hector_munoz
Specialist
Specialist

Hi Pavan,

Could you put an example? I am afraid I donot understand you...

Regards,

H

avinashelite

Expression looks fine for me have you checked the data set that you that condition data or not ? if you have then share the sample data and app let's see what's the issue

Anonymous
Not applicable
Author

Hi Hector,

Pls find the example, I hope it might help you to understand my question.

hector_munoz
Specialist
Specialist

I think something like:

If(Len(Trim(A)) = 0 AND

        Len(Trim(B)) = 0,

        Trim(C),

        Trim(A) & '/' & Trim(B)) AS Reference_Number

, could work fine...

Regards,

H

Anonymous
Not applicable
Author

Thanks for the reply, but No change in the output. Not working for the third condition, when both A and B are null.

Regards,

PV

hector_munoz
Specialist
Specialist

Hi Pavan,

that is the first test I do in the if sentence:

If(Len(Trim(A)) = 0 AND

        Len(Trim(B)) = 0,

        Trim(C),

        Trim(A) & '/' & Trim(B)) AS Reference_Number

I attach you a sample...

Regards,
H

Anonymous
Not applicable
Author

Hi Hector,

Thanks for your help, I wrote a equation as below and it worked,

if (Text(len(Trim ((A))))=0 and text(len(trim((B))))=0,C, (A)&'/'&(B) ) as [Reference Number ]

Thank you,

PV