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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
priyarane
Specialist
Specialist

if Statement

Hi Expets,

How to write the below expression in our Script part.

First(IIf([Template]="Retail",[BaselII_Category] & " Pooled",[Cust_Name]))
If Cust Name is Blank,Null then Use Cust ID. If Cust ID is also blannk use Basel Category

Thank you

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

The isnull() function isn't necessary. Len(trim(...)) is also 0 for null values.

if (Template = 'Retail' ,BaselII_Category &'-'& 'Pooled',

     if(len(trim(Cust_Name))=0,

          if(len(trim(CIF_Cust_ID))=0, BaselII_Category, CIF_Cust_ID),Cust_Name)) as Cust_Name,


talk is cheap, supply exceeds demand

View solution in original post

14 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

First(IIf([Template]="Retail",[BaselII_Category] & " Pooled",[Cust_Name]))

if(Template='Retail',BaselII_Category & ' Pooled',Cust_Name)

No idea what your First does, so I don't know what the Qlikview equivalent is.

If Cust Name is Blank,Null then Use Cust ID. If Cust ID is also blannk use Basel Category

if(len(trim([Cust Name]))=0, if(len(trim([Cust ID]))=0,BaselII_Category,[Cust ID]),[Cust Name])


talk is cheap, supply exceeds demand
Peter_Cammaert
Partner - Champion III
Partner - Champion III

I think there are not one but two expressions in your quote.

  1. This looks like an MS-Access expression. Try:
    FIRST 1 LOAD IF ([Template] = 'Retail', [BaselII_Category] & ' Pooled', [Cust Name]) AS NewColumn FROM ...;

  2. This looks like a requirement in plain English. Try this (replace names with the actual column names):
    IF (len(trim([Cust Name])) = 0, if (len(trim([Cust ID])) = 0, [Basel Category], [Cust ID]), [Cust Name]) AS [Cust Name], ...

Best,

Peter

Peter_Cammaert
Partner - Champion III
Partner - Champion III

In MS-Acces, First() loads the first value in a table column. I didn't know that you could embed IF expressions as a parameter.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Sounds like an aggregation function like FirstValue.


talk is cheap, supply exceeds demand
mukesh24
Partner - Creator III
Partner - Creator III

Can u please explain u r first condition --> First(IIf([Template]="Retail",[BaselII_Category] & " Pooled",[Cust_Name]))

for second u can try -->

if(Isnull([Cust Name])=-1, if(isnull([Cust ID]) =-1, [Basel Category],[Cust ID])

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Could be, but the entire context is missing from the OP. A simple FIRST 1 prefix may be a solution too.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Indeed.


talk is cheap, supply exceeds demand
Not applicable

Hi,

You can try this expression.

=First(If([Template]="Retail",[BaselII_Category] ,"Pooled"),[Cust_Name])

priyarane
Specialist
Specialist
Author

Right now we can leave about First.

Can I write expression like this:

if

(Template = 'Retail' ,BaselII_Category &'-'& 'Pooled',
if(len(trim(Cust_Name))=0 or IsNull(Cust_Name) = -1,CIF_Cust_ID,if(len(trim(CIF_Cust_ID))=0 or IsNull(CIF_Cust_ID) = -1,BaselII_Category))) as Cust_Name,