Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
markgraham123
Specialist
Specialist

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],

1 Solution

Accepted Solutions
sunny_talwar

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?

View solution in original post

18 Replies
sunny_talwar

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

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.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

You can add something like this as an expression:

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

markgraham123
Specialist
Specialist
Author

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

we need group by while using count right???

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

Peter_Cammaert
Partner - Champion III
Partner - Champion III

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

Yes, Peter.

But i wanna do that in script.

Since there were other calculations based on this filed.

jonas_rezende
Specialist
Specialist

Hi, Mark Graham.

Try:

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

I hope this helps!

markgraham123
Specialist
Specialist
Author

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 ???