Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

markgraham123
Valued Contributor

Nested If Statement

Hi, I was trying to do a nested if  statement,

Where if the filed "Name"is null and "Filter count" >1 then i wanna display the field "Dept"

Else "Name"

Can some pls look into this.

If(Len(Trim(Name))=0,Dept, If([Filter Count] > 1,  Dept, [Name])) as [New Column],

Tags (1)
1 Solution

Accepted Solutions

Re: Nested If Statement

May be this:

If(Len(Trim(Name)) = 0 or [Filter Count] > 1, Dept, Name) as [New Column]

My only question is: What is Filter Count? Is it a field in your database?

18 Replies

Re: Nested If Statement

May be this:

If(Len(Trim(Name)) = 0 or [Filter Count] > 1, Dept, Name) as [New Column]

My only question is: What is Filter Count? Is it a field in your database?

markgraham123
Valued Contributor

Re: Nested If Statement

Filter count is the filed, where i'm checking in the script, if the ID has more than one Name.

If so, we wcannot display the same in the straight table with two values , so we will take Dept. instead of Name.

Re: Nested If Statement

You can add something like this as an expression:

=If (Count(Name) > 1, Dept, Name)

markgraham123
Valued Contributor

Re: Nested If Statement

The new column is taking both the fields sunny.

Even after using the above statement,

Name and Dept.

So, we r having 2 values.

markgraham123
Valued Contributor

Re: Nested If Statement

we need group by while using count right???

So, i'm doing a preceding load and using the new filed as "Filter Count"

Re: Nested If Statement

This trick works in the user interface.

If you need this in a Straight Table, you can simply use aggregation as the dimensions of the straight table will do the group-by anyway.

markgraham123
Valued Contributor

Re: Nested If Statement

Yes, Peter.

But i wanna do that in script.

Since there were other calculations based on this filed.

jonas_rezende
Valued Contributor

Re: Nested If Statement

Hi, Mark Graham.

Try:

If(Len(Trim(Name)) = 0 and [Filter Count] > 1, Dept, Name) as [New Column]

I hope this helps!

markgraham123
Valued Contributor

Re: Nested If Statement

Hi Jonas,

The above logic displays Dept. only if both the events occur at same time.

I.e. Len(Trim(Name)) = 0 and also filter count >1 ???