Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
risabhroy_03
Partner - Creator II
Partner - Creator II

If condition

I have 2 fields [Company_Code] and [BOLA].

I have to create a flag based on the below condition - 

If [Company_Code]>300 and [BOLA] should not be blank then 0 else 1.

I wrote this but I don't know how to add the companycode>300 condition.

If(Len(trim("T$BOLA")) = 0,1,0) as [Bola_Flag]

8 Replies
Or
MVP
MVP

If(Len(trim("T$BOLA")) = 0 and companycode>300,1,0) as [Bola_Flag]

risabhroy_03
Partner - Creator II
Partner - Creator II
Author

It doesn't works

risabhroy_03
Partner - Creator II
Partner - Creator II
Author

risabhroy_03_0-1641310411792.png

My BOLA is blank and company_Code>300 it should show as 1 only.

risabhroy_03
Partner - Creator II
Partner - Creator II
Author

I have 2 fields [Company_Code] and [BOLA].

I have to create a flag based on the below condition - 

If [Company_Code]>300 and [BOLA] should not be blank then 0 else 1.

I wrote this 

if(Company_Code>300, If(Len(trim("T$BOLA"))= 0,1,0)
,0) as [Bola_Flag]

but not working as expected

Or
MVP
MVP

That's a dimension. You should be using a measure (or creating your flag in your script).

If you created it in your script, it should work correctly.

risabhroy_03
Partner - Creator II
Partner - Creator II
Author

Didn’t get you

Can you plz explain

Or
MVP
MVP

The code works. If it's not working for you, either your data isn't what you think it is, or you're trying to do this using a calculated dimension.

Load *, if(Company_Code > 300 AND Len(trim("T$BOLA")) = 0,1,0) as Bola_Flag INLINE [
Company_Code, T$BOLA
310,
315,
320,
330,
];

Or_0-1641314719894.png

Since you're getting two rows for each company code, there may be an issue with your data structure or you may have created the Bola_Flag field outside the context of the table which contains the actual value.

MarcoWedel

What did you get instead?

Given which values of Company_Code and BOLA?

Is "T$BOLA" supposed to be the same as BOLA?