Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

Possible to have conditional expressions when two dimensions match


Hi all,

I'm a newbie with qlik so bare with me...

Is it possible to have a conditional expression when two dimensions match?  I have the following table

Fruit       Name                 Fav. Apple          cost

Apple     Fiji                      Gala                   $1

Apple     Gala                   Gala                   $3

Apple     Granny Smith     Gala                   $5

Apple     Red Delicious     Gala                   $2

So in my case I want to only show the sum of the cost when [Fav. Apple] = [Name], or in this case Gala=Gala.

Obviously the data is oversimplified, but is this possible?

I have tried:

if(wildmatch([Name],[Fav. Apple]), sum(cost), "False")

1 Solution

Accepted Solutions
MVP
MVP

Re: Possible to have conditional expressions when two dimensions match

You could use the Like operator:

Name Like 'Gala*'

So Like replace the equal sign and the * is a wildcard meaning any number of characters:

If( Name Like Fav.Apple & '*' , Sum( cost ) )



or



If(  ( Name Like Fav.Apple & '*' ) OR ( Fav.Apple Like Name & '*' ) , Sum( cost ) )

View solution in original post

5 Replies
MVP
MVP

Re: Possible to have conditional expressions when two dimensions match

if you have a straigth table with 3 dimension, Fruit       Name                 Fav. Apple   try with expression

if([Name]=[Fav. Apple]), sum(cost))

Not applicable

Re: Possible to have conditional expressions when two dimensions match

Thanks Massimo.

How would I go about this if the [Name] and [Fav. Apple] are not an exact match?

i.e. Name= Gala, Fav. Apple = Gala, inc

MVP
MVP

Re: Possible to have conditional expressions when two dimensions match

You could use the Like operator:

Name Like 'Gala*'

So Like replace the equal sign and the * is a wildcard meaning any number of characters:

If( Name Like Fav.Apple & '*' , Sum( cost ) )



or



If(  ( Name Like Fav.Apple & '*' ) OR ( Fav.Apple Like Name & '*' ) , Sum( cost ) )

View solution in original post

MVP
MVP

Re: Possible to have conditional expressions when two dimensions match

try

if(index(Name, [Fav. Apple]) or index( [Fav. Apple],Name),sum(price))

Not applicable

Re: Possible to have conditional expressions when two dimensions match

Thanks!  This seems to work for me!