Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Coloful_Black
Contributor III
Contributor III

If conditional statement with AND function

Hi community,

I am trying to create a column at UI's table to list a product type (A, B ,C or D) by using if statement.

my formula at dimension is this :

if ((AVG PRICE) > 10 and (MKT%) > 0.25, "A",
if ((AVG PRICE) > 10 and (MKT%) < 0.25, "B",
if (AVG PRICE) < 10 and (MKT%) > 0.25, "C","D")))

AVG PRICE and MKT% are created measures to help eliminate formula clutter. 

is there anything I miss so my formula does not work?

1 Solution

Accepted Solutions
coloful_architect
Creator II
Creator II

Try to use variable rather than master measure.

I had same issue. Master measure at my Qlik sense version is ok for a simple measurement replacement with color scheme. but when try to insert it with complex set expression formula, it does not necessarily always work.

 

View solution in original post

5 Replies
Lisa_P
Employee
Employee

Use the Expression Editor to create your expression and check if the syntax is correct in the bottom left.

Typically, when you use a master item in an expression, it will be contained in [Square brackets] and your product types should be in single quotes, so try this ..

if ([AVG PRICE] > 10 and [MKT%] > 0.25, 'A',
if ([AVG PRICE] > 10 and [MKT%] < 0.25, 'B',
if ([AVG PRICE] < 10 and [MKT%] > 0.25, 'C','D')))

Coloful_Black
Contributor III
Contributor III
Author

Hi Lisa,

Thanks for the tips on syntax.

however, I tried your way and still does not get any good result. 

Is the set expression/formula supposed to go to dimension or measurement ?

I tried to simplify my expression to tease out what I am missing.

so I created this 

HardToGiveAname2020_0-1626791641627.png

Again, the GP is self created master measures. when I input this, the expression edit shows error like this

  HardToGiveAname2020_1-1626791752474.png

but the output seems good like this ...

HardToGiveAname2020_2-1626791795546.png

now I am totally lost. Any clue?

 

Lisa_P
Employee
Employee

This will also depend on the version you are using. Some of these features are new. If you have another column in the same table as a measure, you can use the title within the same table and it understands.

Coloful_Black
Contributor III
Contributor III
Author

but why my simple if statement ends up with expression error?

I tried to input in both measurement and dimension. all the same.... so confused.

 

coloful_architect
Creator II
Creator II

Try to use variable rather than master measure.

I had same issue. Master measure at my Qlik sense version is ok for a simple measurement replacement with color scheme. but when try to insert it with complex set expression formula, it does not necessarily always work.